Make it Spawn 1 Cube instead of infenity

my scripting problem is on line 71/72 when it spawns the object it keeps spawning non stop i want to limit it to only 1

    var drop : boolean = false;
    var tunnelwidth = 500; 
    var tunnelheight = 200; 
    var tunnel1 = 100; 
    var tunnel2 = 30;
    var law = 500;
    var lah = 230;
    var size = 100;
    var size1 = 25;
    var pickw = 500;
	var pickh = 255;
	var picksize = 100;
	var picksize1 = 25;
	var Cube : GameObject;
	var clone : GameObject;
	var clone1 : GameObject;
 
        function OnGUI ()
        {
            if (details)
            {
		    	
		           if (GUI.Button(Rect(tunnelwidth, tunnelheight, tunnel1, tunnel2), "Cube"))
		           {
		           detaillistActive = !detaillistActive;
		           }
		           if(detaillistActive)
		           {
		           GUI.Box(Rect(law, lah, size, size1), "Cube");
		           if (GUI.Button(Rect(pickw, pickh, picksize, picksize1), "Pick-up"))
		           {
		           pickup = !pickup;
			       }
			       }
           }
           if(pickup)
           {
           if (GUI.Button(Rect(100, 100, 75, 25),"Cube"))
	           {
	           	dropdetails = !dropdetails;
	           }
	           		if(dropdetails)
	           		{
	           			GUI.Box(Rect(law, lah, size, size1), "Cube");
	           			if(GUI.Button(Rect(pickw, pickh, picksize, picksize1), "Drop"))
	           			{
	           				drop = true;
	           			}
	           		}
           }
           if (pickup)
           {
           details = false;
           }
           
           if (pickup)
	           {
	           Destroy (Cube);
	           }
	           
	       if (drop)
	       {
	       		pickup = false;
	       	}
	       if (drop)
	       {
	       	Instantiate (clone);
	       	Instantiate (clone1);
	       } 
      	}
      	

        
       function OnTriggerEnter(other : Collider)
       {
            if(other.tag == "Player")
            {
                details = true;
            }
       }
 
       function OnTriggerExit(other: Collider)
       {
            if(other.tag == "Player")
            {
                details = false;
            }
        }

The reason you’re seeing this happen is that you’re instantiating cube in the OnGUI which is called once per frame. It’s inside a if statement checking if drop is true, but drop is never turned to false, so each frame, after drop is true, you create a new cube.

On a side note about code quality, you should probably brush up on programming skills outside the context of unity and then circle back once you have a solid foundation to build upon.

Example:

if(drop) {
  //does A
}
if(drop) {
  //does B
}

Can turn into:

if(drop) {
  // does A
  // does B
}

Since you already know drop is true.