Button that destroys itself when clicked

Greetings,

Sorry if this is a really stupid question, but I’m having problems and the scripting reference doesn’t really address this. :frowning: (n00b alert)

At the start of my level, I want to draw a GUI box displaying text about what the player will do. I want a button in the box which, when clicked, will destroy itself and the box (" a close window" button). I am having heaps of trouble figuring out how to remove/destroy GUI elements.

Here is my code. The button removes the box, but I don’t know how to get it to remove itself! Any help is much appreciated.

private var showDest : boolean = true; 



function OnGUI()
{	
	if (GUI.Button (Rect (Screen.width/2,Screen.height/2,100,100), "Begin")) {
		showDest=!showDest;		//GUI button that closes window displaying destination
		}
	if (showDest==true) { 
	GUI.Box(Rect(Screen.width/2,Screen.height/2,500,200), "Find your way to "+ destinationname);  //display GUI box at start of level which shows player their destination.
	
	}
	
	
}
var showgui:boolean;
function OnGUI(){
  if (showgui){
    if GUI.Button(whatever){
      showgui=0;
    }
  } 
}

[OSRF]=(or some reasonable facsimile)

And to add to that, that’s the general strategy for showing or hiding any GUI layout – use an outside condition to show the layout to begin with and then have the close button turn it off along with whatever else it needs to do.

I see, thanks. I thought there might be an easier way to do it, but this works for me!