Pause Menu - Loading & Quitting

I’m making a pause menu. One of the buttons quits the game and goes to the main menu. The problem is, when I load another level, the game is still paused, even though it’s a different level. Here’s the code.

The Pauser

functon Update() {

          if(Input.GetKeyUp("p")){
      if(!paused){
       Time.timeScale = 0;
       paused=true;
      }else{
       Time.timeScale = 1;
       paused=false;
      }
     } 
    }

The GUI Menu Button

function OnGUI(){
	   	
	if(paused) {
		
	GUI.backgroundColor = Color.white;
    GUI.contentColor = Color.white;
    GUI.Box(Rect(375,200,Screen.width/2,Screen.height/2), ".");
	}
	
	if(paused && GUI.Button(Rect(600,300,300,40), "Main Menu")){
	
	Application.LoadLevel (" Main Menu");
	
	paused = false;
	}

I thought that by making paused false:

paused = false;

It would work, but still, when I loaded other levels, it was still paused. I’m not sure what to do.

Put a ‘Depauser’ script in your new level, which sets the timeScale back to 1 during the ‘OnLevelWasLoaded’ callback. This way, whenever the level gets loaded, the game automatically unpauses!