(Resolved) Load a Level by pressing a Key

This is my very first script, viewing and learning scripting along the way. I’m trying to have the player load the next level by triggering a box collider. This is what I have so far…not sure what I’m doing wrong. Sorry for being a noob.

#pragma strict

function Update (){
    if(Input.GetKeyDown("e") && enter)
    {
        Application.LoadLevel(2);
    }
}

function OnGUI(){
	if (enter){
	GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100,150,30), "Press E to turn on TV");
}
}

function OnTriggerEnter (other : Collider)
if (other.gameObject.tag == "Player") {
enter = true;
}
}

function OnTriggerExit (other : Collider)
if (other.gameObject.tag == "Player") {
enter = false;
}
}

Here’s how it should look:

#pragma strict
 
var enter : boolean = false;

function Update (){
    if(Input.GetKeyDown("e") && enter)
    {
        Application.LoadLevel(2);
    }
}
 
function OnGUI(){
    if (enter){
    GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100,150,30), "Press E to turn on TV");
    }
}
 
function OnTriggerEnter (other : Collider) {
    if (other.gameObject.tag == "Player") {
        enter = true;
    }
}
 
function OnTriggerExit (other : Collider) {
    if (other.gameObject.tag == "Player") {
        enter = false;
    }
}

In general, if you get a compile error, you should look at the previous line to make sure nothing is wrong. So in your example, the console error was appearing on line 17, but the actual bracket error was on line 16.