waiting before loading level

alright so this is probable really simple (like all the other problems i’ve had so far)

but what i want is that after you’re hit and destroyed, it will wait a little bit before instantly restarting the level…

thanks for the help :smile:

var isPlayerDead:boolean = false;
var waitBeforeRestart:float = 3.0;

function Update(){
    if(isPlayerDead){
        RestartLevel(waitBeforeRestart);
    }
}

function RestartLevel(t:float){
    yield WaitForSeconds(t);
    Application.LoadLevel(Application.loadedLevel);
}