Help with my saving script

So I’m using the following script to try and save my game… any ideas as to why it isn’t working? lol

var levelnumber : int;
function OnEndGame () {
     PlayerPrefs.SetInt("LastLevel", levelnumber);
}


 function LoadLevel () {
     var leveltoload = PlayerPrefs.GetInt("LastLevel");
     Application.LoadLevel(leveltoload);
}
var autoLoad : boolean;

function Start() {
  if(autoLoad==true) {
  LoadLevel();
  }
  if((Input.GetKey("b"))(autoLoad==false)) {
  LoadLevel();
  }
}

Does OnEndGame get called?

Debug.Log(levelToLoad) after you get it and see what the problem is that way.

sure you didn’t want to use OnApplicationQuit