• Godot Help
  • please help: cannot instance script because the class could not be found

Hey, I'm new to Godot, and I got this error. I'm really struggling to find out the cause. I'm using C#, this error happened when I attached a script to a panel in my main scene. Does anyone have any idea what could be going on here? Any help would be very appreciated

Error message:

can_Instance: cannot instance script because the class could not be found

<C++ Error> method failed returning _null

What does the script look like? Might be an incorrect naming somewhere. I think in C# the script and class name needs to be the same. You also have to inherit from a base class (such as Node or Sprite) and give it your unique class name.

    cybereality

    The script used to have a bunch of code in it, but for testing I removed most of the code. Right now, the script is just some imports, the class declaration and the ready function (which is empty):

    using Godot;
    using System;
    
    public class Slot : Panel
    {
        public override void _Ready()
        {
            
        }
    }

    The class name and the script have the exact same name, same capitalization and everything. It's a script for a Panel, so that's what I inherited from as can be seen, do you think I should inherit something higher up on the chain?

    put a simple print statement in that ready and then see if you still get that error. It might just not like an empty method in there.

      Megalomaniak

      That can't be it, I had stuff in the function before and was still getting the error. I removed everything from the function because I was trying to find where the error was

      cybereality

      It's all good, thanks anyway. This error happens whenever I attached a script in my main scene

      I have an update. So, when whenever I edit anything in the script, I get the message:
      Another resource is loaded from path 'res://.mono/assemblies/Debug/Slot.cs' (possible cyclic resource inclusion)

      You will have to include more information about your project. Are there other scripts using that script?

      a year later

      I had two issues causing this for me.

      1. I had a stale script on one of my nodes in the tree. Meaning it showed a script that somehow got deleted from the file system. Check all your scripts.

      2. I had a vanilla static c# script (No godot inheritance). I removed the static and added partial as well as inherited from godot.

      Before:

      After the fix: