How come my GUI window are not closed?

function OnGUI()
{
	if(isWrong)
	{
		GUI.Window(0, Rect((Screen.width/2)-90, (Screen.height/2)-190, 300, 150), showGUI, "Sorry!!");
	}
	
}

function showGUI()
{
	if(isWrong)
	{
		// You may put a label to show a message to the player
		GUI.Label(Rect(65, 50, 200, 80), "Boo..Boo.. WRONG WORDS!!!");
	}
	
	// You may put a button to close the pop up too 
	if (GUI.Button(Rect(60, 90, 75, 30), "OK"))
	{
		isWrong = false;
	}
}

this is my code. I don’t understand how come when i click on ok, the window are not closing??

Try adding the following before your code:var isWrong = false;

Hello. It is inside the code.

I think Ant is pointing out that you haven’t initialized your isWrong variable in the code you posted.

Yes. I mean that i did put inside the code. Just that i did not display on the code when i post on thread.

Could you post all the code in this script… very misleading when people don’t give us all the information.

var isWrong			   	    = false;

function OnGUI()
{
	  
	if(isWrong)
	{
		GUI.Window(0, Rect((Screen.width/2)-90, (Screen.height/2)-190, 300, 150), showGUI, "I'm Sorry!!");
	}
	
}

function showGUI()
{
	if(isWrong)
	{
		// You may put a label to show a message to the player
		GUI.Label(Rect(65, 50, 200, 80), "Boo..Boo.. WRONG WORDS!!!");
	}
	
	// You may put a button to close the pop up too 
	if (GUI.Button(Rect(60, 90, 75, 30), "OK"))
	{
		isWrong = false;
	}
}

you never change the value, it’s allways false…

Sorry everyone, as my code is very very long. So was quite blur in which code i should show. My mistake. I did change the value. Just can’t figure out where gone wrong…

else if(selected_00.GetComponent(textOnMouse00).thisRadical.ID != selected_0.GetComponent(textOnMouse0).thisRadical.ID)
{
	isWrong = true;
	//score   -= 500;
}