Problems with Health/Damage

Hello unity Community !! I am new to the unity software coming from gamemaker and I am wondering if I am doing this script correctly? I am following this tutorial

but every time I hit the capsule the Health doesn’t drop and the capsule doesn’t die either
Also there are no errors.

Enemy Logic

#pragma strict
var Health = 100;

function Update ()
{
	if(Health <=0)
	{
		Dead();
	}	
}

function ApplyDamage(TheDamage : int)
{
	Health -=TheDamage;
}

function Dead()
{
	Destroy (gameObject);
}

Melee System

#pragma strict

var TheDamage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;

function Update ()
{
	if (Input.GetButtonDown("Fire1"))
	{
		var hit : RaycastHit;
		if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward) , hit))
		{
			Distance = hit.distance;
			if (Distance < MaxDistance)
			{
				hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
			}	
		}
	}
}

Hmm i use c# so my javas rusty but i cant see an imediate problem. is the enemy script attached to the enemy?

Also are you sure the hit is triggering? (i use a lot of print(“it swings”); etc to keep am eye on that.

Hmm I don’t know what could be wrong but maybe using OnCollisionEnter would work.

might be a silly question but… you have collider components on these objects, right?

there is also Debug.Log (Unity - Scripting API: Debug.Log) and Debug.DrawRay (Unity - Scripting API: Debug.DrawRay), use them to find out what is going on in the script to narrow down where the problem is.

edit: I’ve also had problems in the past when objects don’t have a layer assigned in the inspector, no layer != default layer, and layers impact how the physics engine does hit detection.