Add script to object error

When I want to attach a script to an object I get an error: "Can’t add component "PlayerMovement’ because it doesn’t exist. Check to see if the file name and class name match. And the names do match!
Someone please help me
tnx

Make sure that PlayerMovement inherits from MonoBehaviour and that the class name is identical to the file name.

Can you give an example im a beginner :confused:

the class name and file name are both PayerMovement

Is it possible to hit play without getting a warning that the project can’t be run due to compilation errors?
You may consider to just post the script here. Don’t forget to use code tags:

Here is the script

Please don’t post screenshots of code! What about the other question? Can you hit play without some compilation warnings?

And no it is not possible to run the game but when i deleted the script there were no errors and i could hit play

What is the exact file name of the script?

PlayerMovement

Try to right click on the script and select “Reimport”. Do you get any error messages in the console?

Yes i do

Do you mind to share them with us? Error messages are kind of important :wink:

Screenshot?

First make sure to clear the console, then reimport again and post the results. You may post a screenshot, but the first messages are the most important ones and need to be visible.

the error:

Could not start compilationWin32Exception: ApplicationName=‘“C:/Program Files (x86)/Unity/Editor/Data/Mono\bin\mono.exe”’, CommandLine=‘“C:/Program Files (x86)/Unity/Editor/Data/Mono\lib/mono/unity\smcs.exe” @ /UnityTempFile-17e1dd46d57cde14fb20e54eed1ec8e3’, CurrentDirectory=‘C:/Users/Sijt/SkyDrive/Documenten/Unity 3D/Unity Projects/Moore/Assets/…’
System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
System.Diagnostics.Process.Start ()
(wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
UnityEditor.Utils.Program.Start () (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Utils/Program.cs:33)
UnityEditor.Scripting.Compilers.MonoScriptCompilerBase.StartCompiler (BuildTarget target, System.String compiler, System.Collections.Generic.List1 arguments, Boolean setMonoEnvironmentVariables) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Scripting/Compilers/MonoScriptCompilerBase.cs:32) UnityEditor.Scripting.Compilers.MonoScriptCompilerBase.StartCompiler (BuildTarget target, System.String compiler, System.Collections.Generic.List1 arguments) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Scripting/Compilers/MonoScriptCompilerBase.cs:20)
UnityEditor.Scripting.Compilers.MonoCSharpCompiler.StartCompiler () (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Scripting/Compilers/MonoCSharpCompiler.cs:48)
UnityEditor.Scripting.Compilers.ScriptCompilerBase.BeginCompiling () (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Scripting/Compilers/ScriptCompilerBase.cs:60)

Does this help you?

Unity can’t start the compiler at all. Did you try to restart your computer? What kind of anti virus application do you have?

I restarted my co puter recently , i use Norton

Does working in the cloud affect any of this?