# "Play Button" (controlling scripts)

**URL:** https://discussions.unity.com/t/play-button-controlling-scripts/575147
**Category:** Scripting
**Tags:** Scripting
**Created:** [April 5, 2015, 12:05am UTC](https://discussions.unity.com/t/play-button-controlling-scripts/575147 "2015-04-05T00:05:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Mr.NewB](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/mr.newb/32/439346_2.png) [@Mr.NewB](https://discussions.unity.com/u/Mr.NewB)
#### Post date: [April 5, 2015, 12:05am UTC](https://discussions.unity.com/t/play-button-controlling-scripts/575147/1 "2015-04-05T00:05:25Z")

</div>

**Hey.**  
i have several scripts running in a screen. when i press play i need to be able to control which script is running and which is not. is there a “easy” way to accomplish this?

this script is attached to my player. i dont know if that’s necessary but i’ll post that too, and want that script to turn off all scripts that i choose.

#pragma strict

function OnMouseDown () {  
GetComponent.().isKinematic = false;  
Cursor.visible = false;  
}

Happy easter!

---

<div class="post-metadata">

### Author: ![Xarbrough](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/xarbrough/32/281179_2.png) [@Xarbrough](https://discussions.unity.com/u/Xarbrough)
#### Post date: [April 5, 2015, 12:12am UTC](https://discussions.unity.com/t/play-button-controlling-scripts/575147/2 "2015-04-05T00:12:17Z")

</div>

Yes, the easy way is to turn off a script via the .enabled bool of your script, which is inherited from MonoBehaviour. If your script includes the Start() function, it will also show a checkbox in the inspector. This represents the .enabled field which is automatically in every component that has a Start() function. Just find a reference to a script and then set script.enabled = false;

---

<div class="post-metadata">

### Author: ![Mr.NewB](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/mr.newb/32/439346_2.png) [@Mr.NewB](https://discussions.unity.com/u/Mr.NewB)
#### Post date: [April 5, 2015, 8:15am UTC](https://discussions.unity.com/t/play-button-controlling-scripts/575147/3 "2015-04-05T08:15:35Z")

</div>

**Thanks Xarbrough.**

I am afraid i am too new to this to understand that you wrote  
But i will try to implement that you said in the script.

---

<div class="post-metadata">

### Author: ![Xarbrough](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/xarbrough/32/281179_2.png) [@Xarbrough](https://discussions.unity.com/u/Xarbrough)
#### Post date: [April 5, 2015, 8:33pm UTC](https://discussions.unity.com/t/play-button-controlling-scripts/575147/4 "2015-04-05T20:33:04Z")

</div>

I can’t see what the script you posted should do, so I’m just explaining how to disable a script:

```csharp
using UnityEngine;
using System.Collections;

public class MainScript : MonoBehaviour {
   
    void Start () {
   
        //Find a reference to your scripts
        DragDrop dragDropScript = Object.FindObjectOfType<DragDrop>();
        Rotation rotationScript = Object.FindObjectOfType<Rotation>();
        //FindObjectOfType is very slow and you need to hardcode the class name

        //Alternatively:
        //Player playerScript = GameObject.FindGameObjectWithTag("Player");
        //dragDropScript = playerScript.gameObject.Getcomponent<DragDrop>();

        //Or if all scripts are on the same gameobjects
        //dragDropScript = GetComponent<DragDrop>();

        TurnOffScript(dragDropScript);
        TurnOffScript(rotationScript);
    }

    void TurnOffScript (MonoBehaviour script) {
        if(script != null)
            script.enabled = false;
    }
}

```

In any case, especially if you don’t know what a reference is, or what the .enabled property means, you can watch this official Unity tutorial: [http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/coding-for-the-absolute-beginner](http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/coding-for-the-absolute-beginner)

---

<div class="post-metadata">

### Author: ![Mr.NewB](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/mr.newb/32/439346_2.png) [@Mr.NewB](https://discussions.unity.com/u/Mr.NewB)
#### Post date: [April 5, 2015, 9:36pm UTC](https://discussions.unity.com/t/play-button-controlling-scripts/575147/5 "2015-04-05T21:36:48Z")

</div>

Thanks Yarbrough!  
i test this as soon as i get home. i really appreciate your help,

---

<div class="post-metadata">

### Author: ![Mr.NewB](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/mr.newb/32/439346_2.png) [@Mr.NewB](https://discussions.unity.com/u/Mr.NewB)
#### Post date: [April 6, 2015, 10:07am UTC](https://discussions.unity.com/t/play-button-controlling-scripts/575147/6 "2015-04-06T10:07:32Z")

</div>

Yes got it working!  
Thank you so much for all your help mr **Xarbrough.** i really appreciate it.
