BCE0044: expecting (, found 'OnGUI'.

Hello,Im trying to make a “game over,restart” menu popup when a 2D collider enters a trigger.At first I made a scene where it shows you a ‘game over’ text and you had to press the retry button to restart and it worked great.Now when I try to make some buttons show up,it gives me these errors :

“Assets/Scripts/Destroyer.js(15,10): BCE0044: expecting (, found ‘OnGUI’.”

And this one :

“Assets/Scripts/Destroyer.js(15,17): UCE0001: ‘;’ expected. Insert a semicolon at the end.”

This is the script im using :

#pragma strict

public var other : GameObject;
var myGUISkin : GUISkin;

function OnTriggerEnter2D(other : Collider2D)
{
if(other.tag == "blackballoon")
{
Destroy (other.gameObject);
}
if(other.gameObject.tag == "balloon")
{
function OnGUI(){
GUI.skin = myGUISkin;

if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2+3,200,50),"Restart")){
Application.LoadLevel(Application.loadedLevel);
    }
}
}
}

Thnak you for your time.

You need to take the time to indent and match your braces. Pick a single bracketing style, not the mix and match as you’ve done here. Once you have your bracketing fixed, you will see that your OnGUI() function is nested inside your OnTriggerEnter2D function. You cannot nest functions. Pulling OnGUI() out to the top level will fix this error.