Unity script error "Can't add script"

When I create a script and try to attach it to a game object, this error comes up. I’m having a hard time figuring out what’s going on. I even reinstalled the engine, but the error is the same.

"Can’t add script

Can’t add script component ‘Player’ because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.
OK"
2026-02-02 11-43-34

Hmm, from the clip I get the impression it didn’t do a recompile at all after you added the script.
Press Ctrl+R to force it to see if that’s the issue.
Am assuming the logs are empty and you haven’t accidentally enabled a log-filter (the top buttons and search field in the log window)?

I have a list of things to check for this error:

There’s nothing immediately obvious from your video what could be causing the problem.

Hey, you must have same names and no compile errors. If you have that I would try:

  1. create a new script in root Asset folder not in Player → Script folder.
  2. check your Edit → Preferences → External tools and make sure your VS is connected as External Script Editor.
  3. Make sure you have all essentials installed in your VS. Run VS installer and make sure you have Unity and C# SDK installed.
  4. delete Library folder in your project and run Unity again. Don’t worry, it is 100% safe.
  5. make sure no space is present in the script name
  6. check your Package manager for errors and updates, especially for VS.
  7. reinstall Unity