Kill Script

I have been trying to make a script that causes certain objects to cause damage to other objects, and when those objects have 0 health, something happens (like they get destroyed). I can’t seem to figure out how to do this. I was wondering if anyone could help and give a basic overview of what everything does (I am very new to Unity).

Okey first you need to make object’s life , like this:

var life : int = 100;
var lifeText = "Life: ";

Then , you need to make the colider and the tags for the objects and add a function for it:

function OnTriggerEnter( other : Collider ) {

    if (other.tag == "Enemy") {
  
   
        life += -5;
        
        
    }
     if (other.tag == "Muerte") {
  
   
        life += -100;
        
        
    }

Your script looks like this(Final Script):

var life : int = 100;
var lifeText = "Life: ";
var customGuiStyle : GUIStyle;


function OnTriggerEnter( other : Collider ) {

    if (other.tag == "Enemy") {
  
   
        life += -5;
        
        
    }
     if (other.tag == "Death") {
  
   
        life += -100;
        
        
    }
    
       if (life <= 0) {
Application.LoadLevel (2); //Or destroy object or anything
}
    

if (life >= 50) {
Application.LoadLevel (3); //Or destroy object or anything
    
}


function OnGUI () {
   
    GUI.Label(Rect((Screen.width / 4.25) + 20,10, 200, 30), "Life: " + life,customGuiStyle); 
    }

Hope it helps ^^