Activating Scripts in another Script?

I only seem to find old solutions for this… its pretty simple. I need to get the Script itself by using GetComponent which i think did it right:

	Component SCRIPT;

	void Start () {

isn’t it?

And after that i can’t find how to set the Script Component to active…

1 Like

By “set the script component to active” I assume you mean enable it (And that it was initially disabled).

Your use of GetComponent() is correct - though in the future I would recommend you make the variable type the name of your component as well.

public GameObject objectThatHoldsScript;
ScriptName script;

From there, once you get the component, just set it’s “enabled” value to true.

void Start() {

  script = objectThatHoldsScript.GetComponent<ScriptName>();
  script.enabled = true;


It’s not “Component script”, its:

SCRIPTNAME variableName; //type of SCRIPTNAME
GameObject myObj; //type of GameObject

variableName = myObj.GetComponent<SCRIPTNAME> ();

The thing to learn here, your script is practically a type of variable, like an int, string or float. It’s not exactly that, and there are some differences, but for this case it’s about the same.