How to restart the game?

  if (hitPoints <= 0) { 
     // Display Game Over and Stop the game.

	  if (gameoverText) {
	     gameoverText.active = true;
	    Time.timeScale = 0;
    }
  }

This code shows the game has pause after it’s game over. I am now wanting to make a GUItext as a replay button, but still wondering how to script to make the application to restart once click the replay GUItext ?

The easiest way is place a script on your botton such as

function OnMouseDown() {
  Application.LoadLevel(1); // Or whatever level
}
function OnMouseDown() {
  Application.LoadLevel(1); // Or whatever level
}

Hmm i tried putting this script into it, but when i click on the button it brings me to another scene >_<". Well as u stated “// or whatever level” , i know i should type it to somewhere to my level but i need some explanation a little on how it works. Tried play around but i still can’t make it to load my level instead of other level.

Try this script:

function OnMouseDown() { 
  Application.LoadLevel(Application.loadedLevelName); 
}
function OnMouseDown() {
  Application.LoadLevel(Application.loadedLevelName);
}

hmm still the same…loaded to the level that is not my level…can i have a brief explain where it will call from the bracket?

Application.LoadLevel(what the script will call from?)

function OnMouseDown () {
      Application.LoadLevel(0);
}

Saying Application.LoadLevel(0) will load the very top level in the build settings. Application.LoadLevel(1) will load the second level in the build settings. The build setting are under “File>>Build Settings…”

OH~ very well! great…thanks for the explanation…now im clear and going smoothly thanks~~

You can also use the scene name you’ve assigned the “level” as well if it’s easier to remember (it is for me in case I move the scene order around later. Thus …

function OnMouseDown () {
      Application.LoadLevel(start);
}

also works.

oh…alright…thanks~