Creating a script doesn't work from the start.

So, sometimes when I create a new script, it creates the script and opens up VS and all that, but when i start coding, nothing works.

From the very second I make it, MonoBehaviour is just regular white, instead of switching to blue(which it does in all of my working scripts), and all the code that comes afterwards is also regular white, except for "void"s, they turn green(as they should).

It sometimes worked to delete the script, and make it again, but now it won’t do anything. I can still write in the other scripts of the project.

I’ve been programming for about a month now, and just started using unity last week, so it might be a stupid mistake, but nonetheless, I can’t find anything about this.

My guess is you are not including the required using statements at the start of the script.

For example MonoBehaviour requires using UnityEngine;

If that is the case and you are using VS and it is correctly configured it should hopefully underline it. In which case you can just hover over it and press ALT + Enter and it will provide a link to insert the missing code automatically.

@unit_nick all the “using” was there, they were already written when I made the C# script.
I still don’t know what the problem was, but it was fixed by restarting the computer, and re-creating it again.

Kind of hoping there’ll be a permanent fix to this, so I don’t have to create the same script 3 times, but it works as of right now.

Hello buddy, that’s a bug with just created scripts.

  • Just close you script editor (mono/visual studio) and open it again

Hope it works