Healthscript not working

My health script is not working and i can’t find the solution. The problem is that if I hit the enemy (a cube for example) with the bullet he won’t die/disappear.

#This is my health script

#pragma strict

var Health : int = 100;
var bullet : GameObject;
var damage : int = 25;

function Update () 
{
	if(Health < 0)
	{
		DIE();
	}
}

function OnTriggerEnter (hit : Collider) 
{
	if(hit.gameObject.tag == "Bullet")
	{
		bullet = hit.gameObject; 
		TakeDamage ();
	}
}

function TakeDamage ()
{
	var GunPreferences : Bullet = bullet.GetComponent("Bullet");
	damage = GunPreferences.Damage;
	Health -= damage;
}

function DIE ()
{
	Debug.Log("I'm dead");
	Destroy(gameObject);
}

#My Gun Script

var Bullet : Rigidbody;
var Spawn : Transform; 
var BulletSpeed : float = 1000;
var ReloadTime : float = 2;
var AmmoInMag: float = 30;
var IsFullAuto = true;
static var AmmoLeft : float;
static var ReloadTTime : float;
private var CanFire = true;
var FireRate = 0.1;

function Start () {
	AmmoLeft = AmmoInMag;
	ReloadTTime = ReloadTime;
}

function Update () {
	if(IsFullAuto == false){
		if(Input.GetButtonDown("Fire1")){
			if(AmmoLeft > 0){
				BroadcastMessage("FireAnim");
				Fire();
			}
		}
	}
	else{
		if(Input.GetButton("Fire1")){
			if(AmmoLeft > 0){
				BroadcastMessage("FireAnim");
				Fire();
			}
		}
	}
	
	if(AmmoLeft == 0)
	{
		Reload();
	}
	
	if(AmmoLeft < 0){
		AmmoLeft = 0;
	}
}
function Fire(){
	if(CanFire == true){
		var bullet1 : Rigidbody = Instantiate(Bullet,Spawn.position,Spawn.rotation);	
		bullet1.AddForce(bullet1.transform.forward *BulletSpeed);
		CanFire = false;
		yield WaitForSeconds(FireRate);
		CanFire = true;
		AmmoLeft -= 1;
		audio.Play();
	}
}

function Reload(){
	CanFire = false;
	BroadcastMessage("ReloadAnim");
	yield WaitForSeconds(ReloadTime);
	CanFire = true;
}

Thanks in advance!!

There are so many factors that could cause this not to work, so without seeing how you have things set up in the editor it’s impossible to narrow down. I will point you at some areas I would look at first:

Line 13 you are checking OnTriggerEnter, so make sure you set your collider to being a trigger.

Line 15 you check if hit.gameObject.tag == "Bullet", so make sure you actually have your bullet prefab tagged as “Bullet”.

Line 25 you assign the value of GunPreferences.Damage to be what you decrease health by, so make sure that is initialized in the Bullet class and not defaulted to 0.

And on a side note, line 7 you probably want to check if(Health <= 0) instead of just <.