Application.LoadLevel() error

I developed a game about cultural education I made 2 scene, mainmenu and MUM scene.

in MUM scene I use this script () to pause n back to main menu

var level : int; var check : boolean = false; var doWindow0 : boolean = false;

function DoWindow0 (windowID : int) {
    if(GUI.Button (Rect (10,30, 150,20), "Back to Menu"))
       Application.LoadLevel(0);

     if(GUI.Button (Rect (10,50, 150,20), "Return to Game"))
     {
        BackToGame();
     }
}

function OnGUI () {

    if (doWindow0)
        window = GUI.Window (0, Rect (Screen.width / 2 - 90,Screen.height / 2 - 45,180,90), DoWindow0, "Pause Menu");
}

function Update()
{

    //I tried to use all of the button events...

    if(Input.GetButtonUp("esc"))
    {
    doWindow0 = true;
    Screen.lockCursor = false;
    Screen.showCursor = true;
    Time.timeScale = 0;
    }

    if(Input.GetButtonDown("esc"))
    {
    doWindow0 = true;
    Screen.lockCursor = false;
    Screen.showCursor = true;
    Time.timeScale = 0;
    }

    if(Input.GetButton("esc"))
    {
    doWindow0 = true;
    Screen.lockCursor = false;
    Screen.showCursor = true;
    Time.timeScale = 0;
    }
}

function BackToGame()
{
Screen.lockCursor = true;
    Screen.showCursor = false;
    doWindow0 = false;
    Time.timeScale = 1.0;
}

when i'm working in MUM scene , i play it and it work ,it loads the mainmenu. but in main menu i can't back to MUM scene by Application.Loadlevel(1). I use this script to load level. a attached it in empty object

var beep : AudioClip;
var menuSkin : GUISkin;
var areaWidth : float;
var areaHeight:float;

function OnGUI(){
    GUI.skin= menuSkin;

    var ScreenX = ((Screen.width * 0.5)-(areaWidth * 0.5));
    var ScreenY = ((Screen.height * 0.5)-(areaHeight * 0.5));

     GUILayout.BeginArea(Rect(ScreenX, ScreenY,areaWidth,areaHeight));

        if (GUILayout.Button("MUM")){
            OpenLevel(1);
        }
        if (GUILayout.Button("MUM2")){
            OpenLevel(2);
        }
        if (GUILayout.Button("quit")){
            Application.Quit();

        }

    /*penutup area GUI*/
    GUILayout.EndArea();
}

function OpenLevel(level : int){

    audio.PlayOneShot(beep);
    yield new WaitForSeconds(0.35); 
    Application.LoadLevel(level);
    Debug.Log("Open level work");

}
@script RequireComponent(AudioSource)

the script working if only i set variable doWidow0 always true...

anyone can help?

I guess you forgot to set `Time.timeScale` back to 1.0 when you're loading a scene.


edit

Well, there are lots of ways to reset the timescale. You can either reset it right after LoadLevel:

if(GUI.Button (Rect (10,30, 150,20), "Back to Menu")){
    Application.LoadLevel(0);
    Time.timeScale = 1.0f;
}

or just Add a Start() or Awake() function into the other script and reset it when the scene is loaded:

function Awake()
{
    Time.timeScale = 1.0f;
}