Why doesn't my enemy take damage?

My enemy stops taking damage after about three seconds from starting the game.

The shooting script is here:

#pragma strict

var Range : float = 1000;
var Force : float = 1000;

var hitMark : GameObject;

var texta : GUITexture;
var four : Texture;
var three : Texture;
var two : Texture;
var one : Texture;
var zero : Texture;
var five : Texture;

var bullets : int = 5;

var shootSound : AudioClip;

function Start () {

}

function Update () {

	if(Input.GetKeyDown(KeyCode.R)){
		
		bullets = 5;
		GameObject.Find("Gun").animation.Play("reload");
	
	}
	
	if(bullets == 5){ texta.guiTexture.texture = five; }
	
			else if(bullets == 0){ GameObject.Find("Gun").animation.Play("reload"); bullets = 5; }
			else if(bullets == 4){ texta.guiTexture.texture = four; }
			else if(bullets == 3){ texta.guiTexture.texture = three; }
			else if(bullets == 2){ texta.guiTexture.texture = two; }
			else if(bullets == 1){ texta.guiTexture.texture = one; }
		
		
		
		var hit : RaycastHit;
				
		var direction : Vector3  = transform.TransformDirection(Vector3.forward);
         

				
			if(Input.GetMouseButtonDown(0)){
		
			bullets--;
		    audio.PlayOneShot(shootSound);
				if(Physics.Raycast(transform.position , direction , hit, Range)){
				
							var hitRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
					
							if(hit.collider.gameObject.tag == "zombie"){
				
							    //hit.rigidbody.AddForceAtPosition( direction * 100 , hit.point);
							    //hit.collider.gameObject.animation.Play("die");
							    Instantiate(hitMark);
							    hit.collider.gameObject.SendMessage("ApplyDamage", 25);
								
								
						    }
				
				}
			}			
}

And the enemy script:

var target : Transform; //the enemy's target
var moveSpeed = 3; //move speed
var rotationSpeed = 3; //speed of turning

var myTransform : Transform; //current transform data of this enemy
var isNotDead : boolean = true;
var health : float = 100;
function Awake()
{
    myTransform = transform; //cache transform data for easy access/preformance
}

function Start()
{
     target = GameObject.FindWithTag("Player").transform; //target the player

}

function Update () {
	
	if(health < 1){
	
		isNotDead = false;
		animation.Play("die");
		Destroy(gameObject, 1);
	}
	
	if(isNotDead){
	
	    //rotate to look at the player
	    myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
	    Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
	
	
	    
	    var distance = Vector3.Distance(target.position, myTransform.position);
	    if (distance < 3.0f) {
	        animation.Play("attack1");
	    }
	    else{   
	    	//move towards the player
	   		myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
	   		animation.Play("walk1");
	    }

	}
}

function ApplyDamage(dmg : float){

	health -= dmg;

}

Try using something different to ‘Range’ as it is a keyword (struct) unless of course you intended this. Where range is placed in the raycast args is the field for the layermask which is a selector which is used to selectively ignore layers.

http://answers.unity3d.com/questions/8715/how-do-i-use-layermasks.html

Also, if the 3 seconds coincides with a reload make sure that you are reloading the active gun and not everything tagged with “Gun”.

You code

if(Input.GetMouseButtonDown(0)){
 
bullets--;

may not catch the bullets == 0 condition. You might need an if(bullets > 0) in there. Debug.Log(bullets) to see if your bullets are entering negative values.

Look at this thread on SendMessage and consider GetComponent instead. I have a feeling that SendMessage might not be right in this case, if you use the script on multiple enemies containing ApplyDamage (I could be wrong), but SendMessage is much slower in any case.

Looking around, people are having trouble with ++ and --.
Swap bullets–; for bullets -= 1;

Fixed:

Shooting Script:

#pragma strict

var Effect : Transform;
var TheDammage = 100;
var hitMark : GameObject;
function Update () {
	
	var hit : RaycastHit;
	var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
	
	if (Input.GetMouseButtonDown(0))
	{
		if (Physics.Raycast (ray, hit, 100))
		{
			hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
			
			if(hit.collider.gameObject.tag == "zombie"){
					
							    //hit.rigidbody.AddForceAtPosition( direction * 100 , hit.point);
							    //hit.collider.gameObject.animation.Play("die");
							    Instantiate(hitMark);

								
								
						    }
		}
	}
	
}

Enemy Script:

#pragma strict

var Health = 100;

function ApplyDammage (TheDammage : int)
{
	Health -= TheDammage;
	
	if(Health <= 0)
	{
		Dead();
	}
}

function Dead()
{
	Destroy (gameObject);
}