How to turn off a script in Unity

I have a very concrete question. How do I turn off a script in unity C#.

People are talking about that they have done it and the video documentation says it is possible to do so, but nobody ever explains how to do it.

Could someone please explain to me in detail how to do it.


A script is basically a ordinary component.
In C # you have several possibilities to access a component.

You can use a public variable :

Or just use GetComponent on the Gameobject yout put the script on :

public MonoBehaviour MyScript01; // You can put every MonoBehaviour into it

private "Class Name" MyScript02;


void Start ()
     MyScript02 = Gameobject.Find("Placeholder").GetComponent<"Class 

To Deactivate / Activate the Script you simply say :

void DeactivateScript (bool Activate)
        MyScript01.enabled = true;
       MyScript01.enabled = false;

I hope it helped you.

I just can’t figure out what is meant to be placed instead of “Placeholder”, I checked the documentation and it says it should be the name of a gameobject between two “” and that a gameobject is defined as for example a cube which may have scripts and other things attached to it. Which means as I understood it the name of the gameobject on top above the transform, I tried both the parent gameobject and the child gameobject of the gameobject holding the script to turn off and the gameobject of the gameobject which should hit the gameobject with the script to turn off, but I only got null pointer exception each time meaning wrong value is written between the paranteses. I think this “placeholder” is the only thing I have not figured out could you please explain what should be written there.