Re Setting PlayerPrefs From Splash Screen

My splash screen is level 0. I've got PlayerPrefs set up so that from my splash screen, if the PlayerPrefs "SavedLevel" is 1 or more, then the player goes straight to level 3 of the game. Otherwise they have to go through level 1 and level 2.

That part of the script worked fine.

On occasion, I want to re-set the PlayerPrefs "SavedLevel" to 0 by pressing the "enter" key whilst the splash screen is showing, and then make the player go through level 1 and level 2.

To do this, I added the function Update part at the bottom of the script, but it's not working. I still go straight to level 3.

Can someone please let me know what's wrong with the below script, and how I can change the PlayerPrefs from my splash screen?

Thanks.

var levelreached : int;

//Allows time for text to be read
yield new WaitForSeconds (20.00);

//Checks PlayerPrefs number
levelReached = PlayerPrefs.GetInt("SavedLevel"); 

//If playerPrefs is 1 or above, goes from splash screen to main menu
if (levelReached >= 1 ){
Application.LoadLevel(3);
}

else{
   // moves to instruction level
   Application.LoadLevel(1);
}

//Allows player to zero playerPrefs if they press "enter" during splash screen.
//Sets PlayerPrefs to zero
function Update () {
if (Input.GetKeyDown ("space")) {
PlayerPrefs.SetInt("SavedLevel",0);
 Application.LoadLevel(1);
}
}

you might as well try Input.GetButtonDown("Enter") and set it in the Input Manager, this way you can make a button on a joystick to work for it too. And just a reminder, if you check PlayerPrefs in a new machine instead of zero it will return a PlayerPrefs Exception, make a check and set it if it doesn't exist

The problem may be with using yield in the code that is not wrapped by a function. I believe that's the Javascript equivalent to putting code in Awake, and you can't have yield in Awake.

Haven't tried this myself, but try calling a different function from the Awake code and put your logic there. According to this discussion that may work.

Are you sure it's not because you're checking for space instead of enter/return?

try

if (Input.GetKeyDown(KeyCode.Return))

instead, and see if that helps