Disable mouse look when a button is pressed

Well i have this code that should work but it’s not working, help anyone?

if (Input.GetButtonUp("escape"))
GetComponent("MouseLook").enabled = false;
else if (Input.GetButtonUp("escape"))
GetComponent("MouseLook").enabled = true;

Off top of head I don’t see a reference to the object you’re trying to disable at the GetComponent level… is the mouselook script attached to the same gameobject that has the script with your posted code?

/
/
GameObject.Find("blah").GetComponent<MouseLook>().enabled = false;
/
/

EH?

Give your MouseLook GameObject a tag with a name of your choosing, and replace the “Tag” with your tag name.
This should work provided that you’re using Unityscript, and “MouseLook” is a script, and “enabled” is a variable within that script.

var mL : MouseLook;
function Update()
{
mL = GameObject.FindWithTag("Tag").GetComponent("MouseLook");

if (Input.GetButtonUp("escape"))
{
mL.enabled = true;
}

else if (Input.GetButtonUp("escape"))
{
mL.enabled = false;
}
}

Good luck!