Make the game stop if you get hit by enemy object

So what i wants to know is, how i make the game stop when, you get hit by a enemy object.
if we say the health is 1; var Health : int = 1
And then something like
if (Health == 0)
(STOP GAME)

Something like that, just with some new commands, and stuff that i don’t know. I just started scripting so… yeah…
Well i want the health to go to 0 when hitting an enemy object, and that activates the ‘‘if statement’’ and stops the game.
I think it sounds simple, but i don’t know how simple it is. Could anyone post a script, doing what i just said, with the same var and if statement as i used (not some other statement that does the same as them)
And please explain what the things do, cause that is mostly what i want to know.
Thanks.!

Well by hitting you mean colliding then you can do something like this:

function OnCollisionEnter(other: Collision) {  //listens for collisions in your game
// you can read more about this http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html
  if(other.Tag=="Enemy"){ //check if that you bumped into an enemy
    Health=Health-1;      //decrease your health
    if(Health<=0) {       //if your health is 0 then stop game, exit what so ever
      Time.timeScale = 0; // this will freeze the game, stop
      // you can also use the following if you want the game to exit
      //Application.Quit();
      //or reload current level
      //Application.LoadLevel(Application.loadedLevel);
    }
  }
}

I usually don’t script in javascript so it may be some bugs or too, but this is the basic concept. Just attach this script to your player, add Enemy tag to your enemies, declare the health variable with the starting health and attach colliders both for you and your enemies.

EDIT: FINAL ANSWER: So the thing was that you where using character controller which doesn’t have nor rigid body nor collider, but it has a special function, so modify your script like this:

var Health = 1;
function OnControllerColliderHit(hit: ControllerColliderHit){
	if(hit.collider.tag=="Enemy"){ //check if that you bumped into an enemy
    Health=Health-1;      //decrease your health
    if(Health == 0) {       //if your health is 0 then stop game, exit what so ever
      Time.timeScale = 0; // this will freeze the game, stop
      // you can also use the following if you want the game to exit
      //Application.Quit();
      //or reload current level
      //Application.LoadLevel(Application.loadedLevel);
    }
  }
}

You can remove the rigidbody from your “lava” cubes, it only needs a collider. So this script as it is will stop time in your script, nothing will move ( but you will be able to move the camera) if you just one to restart, then use last commented code instead with the loadlevel.

If you ahve any other question just ask.

//attach this script to "lava "
//kubo is palyer name

void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.name == “kubo”)
{

        Destroy(col.gameObject);
    }
}