Gui button is always active?

So I have this script and whenever the gui button is pressed it Debugs the message I want hundreds of times. Also when I make it spawn a prefab it spawns it hundreds of times and it won’t stop until I exit game mode. Here is my script:

var rType = 0;
	var script : Selecting_System;
	var Corridor = false;
	public var prefab : GameObject;
	public var instObj : GameObject;
	function OnGUI() {

		

		if (GUI.Button(Rect(10,70,50,30),"Click")){
			rType = 1;
			Debug.Log("Clicked the button with text");
	}

		if (GUI.Button(Rect(10,140,50,30),"Click")){
			rType = 2;
			Debug.Log("Clicked the button with text");
	}
					if(rType == 1)
				{
					if(script.selected1 == true)
					{
						Debug.Log("Success");
						Corridor = true;
						instObj = Instantiate (prefab, Vector3(1.0316, 1.031601, 0), Quaternion.identity); 
					}
				}

					if(rType == 2)
				{
					if(script.selected2 == true)
					{
						Debug.Log("yay");
					}
				}
}

Add a boolean to prevent it

var wasInstantiated : boolean;

//Code
if(script.selected1 == true && !wasInstantiated)
{
  Debug.Log("Success");
  Corridor = true;
  instObj = Instantiate (prefab, Vector3(1.0316, 1.031601, 0), Quaternion.identity);
  wasInstantiated = true;
}

Another posibility is to write rType = 0 when you instantiate

//Code
if(script.selected1 == true && rType == 1)  //BTW, && means 'and'
{
  Debug.Log("Success");
  Corridor = true;
  instObj = Instantiate (prefab, Vector3(1.0316, 1.031601, 0), Quaternion.identity);
  rType = 0;
}

If rType == 1 and script.selected1 == true, that code is going to execute every frame. Maybe you need to move the rType declaration (var rType) into your OnGUI() function.

Would you need to do a function that is like: function OnMouseUp(){Code In Here}