Disabling a Script with C#

I am trying to create a script disable another script attached to the same GameObject.

I am using the following line:

 GetComponent<ScriptName>().enabled = false;

However, I get this error:

`error CS0246: The type or namespace name 'ScriptName' could not be found. Are you missing a using directive or an assembly reference?`

What am I doing wrong? Thank you in advance!

ScriptName is not a type that exists in your scope. Most of the time that just means you got the name wrong. But with the current information , that's all I can guess. Either that or you built it in some other project or library that isn't included yet and you need to import it with a using reference, the compiler friendly as it is, assuming you never make a typo.

I found a solution to my problem.

Although it is probably not the best possible solution, I placed the scripts I was referring to in the `Standard Assets` folder inside my project.

In this way, Unity compiles the scripts I was referring to before the script in which I wrote GetComponent<ScriptName>(). (See the Unity documentation for more info)

Hello. First that script u are disabling must exist. you need to change that ScriptName to real scriptname
to your REAL script name instead of “ScriptName”