Death upon health = 0

Any help would be appreciated, we are trying to figure the best way to create a death; whether the app should just close, or a death room, anything really. We are having a very difficult time working through this issue and any help would be appreciated; here is our health script;

var fullHealth : int = 100; 

var curHealth : int = 100;  

function OnCollisionEnter(collision: Collision) 
{
    switch (collision.gameObject.tag)

{case "Enemy" : 

        curHealth -= 1; 
        print ("hit");
        break;

        case "heal" : 
        curHealth += 50; 
        print ("got health");
        break;
		
    }
}

function Update () 
{

    if(curHealth >= fullHealth)
    { 
        curHealth = fullHealth; 
    }

    if(curHealth <= 0)
    {
         curHealth = 0; Debug.Log("You Died");
    }
}

function OnGUI()
{
    GUI.Label (Rect (55, 625, 200, 40),"" +curHealth.ToString()); 
}

It depends on what you want to do when your player dies. Do you want the app to close? That doesn’t seem likely. When you say “death room”, I assume you mean a place that you would go to after the player dies. In this case, you would create a new Scene (File > New Scene), call it “Death Room” or something similar, and where you call Debug.Log("You Died");, instead call this:

Application.LoadLevel ("Death Room");

Similarly, if you’d like to just restart the level, you can call:

Application.LoadLevel (Application.loadedLevel);

Basically, whatever you decide, you just need to use Application.LoadLevel to move your player to the proper place.

GhilleMonsters : I do not fully understand your need.

You seem to ask for a design question but then you have your script here. Let me tell you from what I have understood.

On Coding-wise :

I do not see any issue with your code though. It seems good.

On Design-wise :

When the player runs out of health, I do not think you should “close the app”. It is offensive. You should cut this screen and take the user to another screen where he could see his result. Or you could just stay in the same screen and initiate a pop-up.

Combing Both :
I am not good in UnityScript, so here is a equivalent C# script for you.

using UnityEngine;
using System.Collections;
 
public class HealthController: MonoBehaviour 
{
	
	int CurrentHealth, FullHealth;
	
	void Awake ()
	{
		CurrentHealth = 100;
		FullHealth = 100;
	}
	
	void OnCollisionEnter (Collision hit)
	{
		if(hit.collider.tag == "Enemyy")
		{
			CurrentHealth--;
			Debug.Log("It is a hit");
			
		}
		
		if(hit.collider.tag == "heal")
		{
			CurrentHealth += 50;
			Debug.Log("Health Obtained");
		}
	}
	
	
	void Update ()
	{
		if(CurrentHealth >= FullHealth)
			CurrentHealth = FullHealth;
		
		if(CurrentHealth <= 0)
		{
			CurrentHealth = 0;
			Debug.Log("You Died");
			
			/*
			 // Here you can do lots of things, such as 
			 
			  Application.LoadLevel("FinishScreen");
			  
			 // Display a UI to show the result to player and give him options, such as 
			 
			  /// Restart the game
			  ///  Quita the Game
			  /// Main Menu
			 */
		}
		
	}
}

Hope this helps you. If not, buzz me I will see to provide more help from your scenario.

Cheers!!!