GUI RPG Skill system window

Hey!

I have a problem that I hope I can get help with.

Basicly im trying to make a RPG type of game. I need it like when I press [z] on the keyboard it comes up a window. I am using a GUI.Box now so that’s fine, no custom texture needed. I’m coding in javascript and I would be glad if anybody tried to help me :). This is how my code looks now:

#pragma strict

var skillIsOpen : boolean = false;

function OnGUI () {
	if(Input.GetKeyDown(KeyCode.Z)) {
		if(skillIsOpen == false) {
			skillIsOpen = true;
		}
		else {
			skillIsOpen = false;
		}
	}
	
	if(skillIsOpen == true) {
		GUI.Box(Rect(5, 5, 750, 750), "");
	}
}

Thanks
//Proximal-Pyro

I’m new to coding so this might be wrong, but shouldn’t your if statement to check if they press Z be in the update function so it is constantly getting called? or is the ongui function also called every frame?

Yes check the key in the Update function, if im not mistaken OnGUI get called multiple times during one frame, which could lead to your variable being false the whole time.

Now it works thanks(plus i forgot to attach the script! Faceplam on me :P)