Respawn Button

I am making a running game but I want to make a button so if you fall from the platform, you could simply press something like r to respawn.

How can i make this.

greetings jelle

Trust me, i,ve tried this several times on my own game because i also wanted a restart button

function OnGUI () {

if (Event.current.Equals (Event.KeyboardEvent (“r”)))
Application.LoadLevel(Application.loadedLevel);

}

Hope this helps

Where must i place this script to let it work?