i'm beginner in unity ! my problem is i can't count the number of zombie killed ! this script ZombieHelath is attached to zombie , i'm using javascript !Please help

#pragma strict
var ZombieHealth : int = 100 ;
function OnCollisionEnter (col : Collision) {
if ( col.gameObject.tag == “Bullet”) {
ZombieHealth -= 25 ;
}
}

function Update () {

if ( ZombieHealth <= 0 ) {
GetComponent.().Play(“back_fall”);
gameObject.GetComponent(ZombieAI).enabled = false ;
gameObject.GetComponent(CharacterController).enabled = false;
Dead () ;
}
}
function Dead () {

yield WaitForSeconds (5) ;
Destroy ( gameObject) ;

}

I’m not much help, but you might get some help if the code was a bit easier to read so I’ve formatted it for you.

What I can see is that the zombies are dying but you’re not counting them anywhere. Maybe put in a counter into the Update() function? I don’t know JS but I’ll try to help out, I’ve added a couple of lines in red:

#pragma strict
var ZombieHealth : int = 100 ;

var DeadZombies : int = 0;

function OnCollisionEnter (col : Collision) 
{
         if ( col.gameObject.tag == "Bullet") 
         { 
                ZombieHealth -= 25 ; 
         } 
}

function Update () 

{
        if ( ZombieHealth <= 0 ) 
        { 
               GetComponent.().Play("back_fall"); 
               gameObject.GetComponent(ZombieAI).enabled = false ; 
               gameObject.GetComponent(CharacterController).enabled = false; 
               Dead () ; 

DeadZombies +=1;

        } 
} 

function Dead () 
{

        yield WaitForSeconds (5) ; Destroy ( gameObject) ;

}

You could read DeadZombies as a public variable (unsure how this is done in JS) and have it displayed on a GUI object.