How to activate a specific script in a Prefab.

using UnityEngine;
using System.Collections;

public class playselection : MonoBehaviour {

	public Component moveScript;

	// Update is called once per frame
	void Update () {

		if (Input.GetMouseButtonDown(0))
		{
			moveScript.enabled = true;
		}

		else
		{
			moveScript.enabled = false;
		}
	
	}
}

I have been trying to active a specific script that is located within the object (cube move) but for whatever reason it is not letting me do that. This is the script that is on the GUI texture, i want it so that once the GUI text is pressed, the cube move script is activated and the controls of the player resume.

Once they have resumed, i need the gui text to delete (destroy).

Help, please!

There is no ‘enabled’ property in a component. Usually the the hierarchy is:

  Object-->Component-->Behaviour-->MonoBehaviour-->YourScript

The enabled flag is in Behaviour class, so you can make ‘moveScript’ of any of the types above component. Typically I see either MonoBehaviour, or YourScript.

If by “Prefab”, you mean an instantiated gameObject that is actually in your scene:

Change the word “Component” in line

public Component moveScript;

to the actual class name of the moveScript. So, if your script has the name MoveScript.cs, the line would be:

public MoveScript moveScript;