Can't add Script: The script needs to derive from MonoBehaviour

Having trouble adding a C# script. Keep getting the script needs to derive from Monobeaviour error.

Here’s the script and I can’t find where the mistake is.

Anyone able to help?




Are there any other error messages at all?

Check the filename of the script. It has to exactly match the name of the class. Including any capital letters.

1 Like

Yep, make sure there are no compile errors in the entire project (can’t add a script to an object if it hasn’t already successfully compiled), and that the file’s name is exactly PlayerMovement.cs.

Awesome. Thanks! Got it working.

1 Like