When I go inside a collider I want GUI Text to appear, and allow me to press 'e' to swap scenes, but it instantly transports me to the scene.

When I go inside a collider I want GUI Text to appear, and allow me to press ‘e’ to swap scenes, but it instantly transports me to the scene. I’ve tried but it doesn’t work, heres my script:

#pragma strict

private var AllowBasement;

function OnTriggerEnter()
{
	AllowBasement = true;
}

function OnTriggerExit()
{
	AllowBasement = false;
}

function OnGUI()
{
	if(AllowBasement == true);
	{
		GUI.Box(Rect(0, 0, Screen.width, Screen.height), "Press 'e' to go to the basement");
	}
}

function Update () {
	
	if(AllowBasement == true);
	{
		if (Input.GetKeyDown("e"));
		{
			Application.LoadLevel("Basement");
		}
	}
}

When I use this script the game automatically transports me to basement, Help?

Give this a try and let me know if anything improves, the only real thing that I change is the way the if statements are written, along with a proper declaration of you AllowBasement boolean and its initialization :

#pragma strict

private var AllowBasement : boolean;

function Start() {
    AllowBasement = false;
}

function Update() {

    if (AllowBasement == true) {
    
        if (Input.GetKeyDown("e")) {
            Application.LoadLevel("Basement");
        }
    }
}

function OnTriggerEnter() {
    AllowBasement = true;
}

function OnTriggerExit() {
    AllowBasement = false;
}

function OnGUI() {
    if (AllowBasement == true) {
        GUI.Box(Rect(0, 0, Screen.width, Screen.height), "Press 'e' to go to the basement");
    }
}