Creating a Unpause Button/Resume Game Button

I have started creating a Pause menu however i am stuck creating the unpause menu button for my pause menu. I have tried everything. I have looked all over google and Unity and i couldnt find a working solution/script.

Here is my Pause menu script, It is not finished yet but this is where i have got to until i need to create my resume game button:

var mainMenuSceneName : String;
private var pauseEnabled = false;


function Start(){
	pauseEnabled = false;
	Time.timeScale = 1;
	AudioListener.volume = 1;
	Screen.showCursor = false;
}

function Update(){

	//check if pause button (escape key) is pressed
	if(Input.GetKeyDown("escape")){
	
		//check if game is already paused		
		if(pauseEnabled == true){
			//unpause the game
			pauseEnabled = false;
			Time.timeScale = 1;
			AudioListener.volume = 1;
			Screen.showCursor = false;			
		}
		
		//else if game isn't paused, then pause it
		else if(pauseEnabled == false){
			pauseEnabled = true;
			AudioListener.volume = 0;
			Time.timeScale = 0;
			Screen.showCursor = true;
		}
	}
}
function OnGUI(){

	if(pauseEnabled == true){
	
				if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2 ,250,50), "Options")){
		if(pauseEnabled == true){
			//unpause the game
			pauseEnabled = false;
			Time.timeScale = 1;
			Screen.showCursor = false;
			}
		}
}

Please can you tell me how to fix my script because i am getting a error saying that it is expecting “{” instead it found ". I have no idea how to fix it.

Can you please post a basic resume game button for my script that will work (My script it written in Javascript)

Or

Can you give me the code for a resume game and i can implement the code into my script.

Thanks in advanced.

UniqueGaming

Here you go matey.
Just copy this revised code over and you ll be fine
(this obviously needs to be attached to a gameobejct in your scene.
#pragma strict
var mainMenuSceneName : String;
private var pauseEnabled = false;

    function Start()
    {
    pauseEnabled = false;
    Time.timeScale = 1;
    AudioListener.volume = 1;
    Screen.showCursor = false;
    }
     
    function Update()
    {
	    //check if pause button (escape key) is pressed
	    if(Input.GetKeyDown("escape"))
	    {
		    //check if game is already paused
		    if(pauseEnabled == true)
		    {
			    //unpause the game
			    pauseEnabled = false;
			    Time.timeScale = 1;
			    AudioListener.volume = 1;
			    Screen.showCursor = false;
		    }
	     
		    //else if game isn't paused, then pause it
		 	else if(pauseEnabled == false)
		    {
			    pauseEnabled = true;
			    AudioListener.volume = 0;
			    Time.timeScale = 0;
			    Screen.showCursor = true;
	    	}
	    }
    }//end Update function
    function OnGUI()
    {
     
	    if(pauseEnabled == true)
	    {
		    if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2+25 ,250,50), "Option"))
		    {
		    	Debug.Log("GUI.Button : Options : pressed");
		    }
		    if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2-25 ,250,50), "Resume"))
		    {
			    if(pauseEnabled == true)
			    {
				    //unpause the game
				    pauseEnabled = false;
				    Time.timeScale = 1;
				    Screen.showCursor = false;
				    AudioListener.volume = 1;
			    }
		    }
    	}
}//end OnGUI function    

Your issue was curly braces.

as a humble tip: When you look at a debugger line in the Unity Console…

Assets/dunno.js(61,1): BCE0044: expecting }, found ‘’.

Consider it in three parts.

Like so…
It is saying in the first section

Assets/YourScript.js(61,1)

that the error comes from the script named (YourScript)…
In the second section

BCE0044: expecting },

it`s telling you what the compiler was expecting to find, in this case a “}” closing curly brace, to end your function body.

Thirdly, it is simply telling you WHAT it ACTUALLY found/discovered, in this case nothing!, Nada!, nowt. Represented by the ‘’ part at the end of the sentence.

SO if you can split it into those three each time, you wont go far wrong and any variations, now you know this, are only ever slight with respect to the error statements Unity throws.

Anyhoo, hope that helped ya bud…
If so mark it as an answer as it may help others in the same pickle.
Also, try here for a few pointers and tips for good
Unity development…

Unity Tuts

Unity Gems

take care bud and thanks for reading
Gruffy