Please help I don't understand what is wrong.

Okay I am trying to make a GUI pop up after completing a set number of laps but I’m getting all these errors with the coding that I have put in saying to put something in instead of what I have and when I do what it is asking it just brings up even more errors. My code is in Javascript, I have a lot of things commented out because they worked and I wanted to keep them in so if I fail at adding this pop up I can have my original coding. If at all possible when explaining what I did wrong could you make it as thorough and simple as possible because I am extremely new to programming and can barely understand it Thank you very much for your help.

function OnTriggerEnter(other : Collider){

if (score <= 2){

	score = score + 1;

	print(score);

	}

else

{

	function OnGUI()

	{

 	//(Application.LoadLevel("Tutorial Level"));

 	// Make a group on the center of the screen

		GUI.BeginGroup (Rect (Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 100));

	// All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.

	// We'll make a box so you can see where the group is on-screen.

		GUI.Box (Rect (0,0,100,100), "Do you want to continue with the Tutorial or move on to the real tracks?");

		if (GUI.Button (Rect (10,40,80,30), "Yes"))

			{

			Application.LoadLevel("Tutorial Level");

			}

		if (GUI.Button (Rect (30,60,100,50), "No"))

			{

			Application.LoadLevel("Title GUI");

			}

	// End the group we started above.

	GUI.EndGroup ();

 	}

}

The OnGUI function shouldn’t be inside OnTriggerEnter, it should be on it’s own.
OnGUI is a special built-in function, that is run multiple times every frame.
So, it’s constantly checking whether there are commands inside it to execute (this is also why it can be slow, when it is used too often).

To trigger the dialog, you could use a boolean (true / false) to tell OnGUI whether it should display your message box.

var showDialog : boolean; // can be set to true or false, to decide whether to show the UI
var score : int; // for the score

function OnTriggerEnter(other : Collider)
{
     if (score <= 2)
     {
          score = score + 1;
          print(score);
     }
     else
     {
          showDialog = true; // show the UI
     }
}

function OnGUI()
{
     if (showDialog) // if the showDialog boolean is true ...
     {
          GUI.BeginGroup (Rect (Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 100));
          GUI.Box (Rect (0,0,100,100), "Do you want to continue with the Tutorial or move on to the real tracks?");
          if (GUI.Button (Rect (10,40,80,30), "Yes"))
          {
               // load level
          }
          if (GUI.Button (Rect (30,60,100,50), "No"))
          {
               // load level
          }
          GUI.EndGroup();
     }

 }