GUI.button just isnt responding

Hey I’ve been searching up and down to try and figure out whats going wrong in this code for my GUI.Button but to no avail i still haven’t been able to figure out why the button isn’t working the problem is that when i click the button it doesn’t have any effect here is my code

	public bool play;

	public GUISkin theSkin;

	void Start(){
		play = false;
	}
	void OnMouseUpAsButton(){
			play = true;
	}
	void Update(){
		if (play == true) {
			Application.LoadLevel(1);
		}
	}

	void OnGUI(){
		GUI.skin = theSkin;
		GUI.Button (new Rect (Screen.width / 2 - 140, Screen.height / 2 - 75, 300, 100), "PLAY");
		GUI.Button(new Rect(Screen.width/2-140, Screen.height/2+30, 300, 100),"QUIT");

     }
 }

Well you did not set any functionality for the buttons. You can do it like this:

if(GUI.Button (new Rect (Screen.width / 2 - 140, Screen.height / 2 - 75, 300, 100), "PLAY"))
{
   play = true;
}

if(GUI.Button(new Rect(Screen.width/2-140, Screen.height/2+30, 300, 100),"QUIT"))
{
   Application.Quit();
}

I hope you didnt expect that it will find out from the string that you want to play or quit :slight_smile: