GUI button open a new GUI window with GUI buttons

Hello, I’m trying to make a Main Menu in unity and I have create a world etc. for the background. The Menu is controlled by a GUI script “MainMenu” in javascript attached to a Empty Object in world. I’m trying to make the “Play” button open a new menu with the chapers of the game… but when I press the button, nothing happens.

Code:

`// JavaScript

var missionsmenu = false;

function OnGUI () {

GUI.Box (Rect (10,10,100,160), "Main Menu");

if (GUI.Button (Rect (20,40,80,20), "Play")) {
MissionsMenu = true;
if (missionsmenu)
missionsGUI();
}

if (GUI.Button (Rect (20,70,80,20), "Loadout")) {
Application.LoadLevel(1);
}

if (GUI.Button (Rect (20,100,80,20), "Options")) {
Application.LoadLevel(2);
}

if (GUI.Button (Rect (20,130,80,20), "Quit")) {
	Application.Quit();
}

}

function missionsGUI() {

GUI.Box (Rect (100,10,100,160), "Chapters:");
	if (GUI.Button (Rect (120,70,80,20), "Chapter 1")) {
Application.LoadLevel(3);
}
	if (GUI.Button (Rect (120,70,80,20), "Close")) {
missionsmenu = false;
}

}

`

Change this:

if (GUI.Button (Rect (20,40,80,20), “Play”)) {
MissionsMenu = true;
if (missionsmenu)
missionsGUI();
}

to be this:

if (GUI.Button (Rect (20,40,80,20), "Play")) {
   MissionsMenu = true;
}

if (missionsmenu)
   missionsGUI();

That first If statement will only run the first time you click it, then immediately disappear. I’m surprised you aren’t seeing it flicker on just once.