How to make an enemy lose damage

I am rather new to the coding side of Unity and I have a problem with my JavaSvcript code. I have two codes, both are supposed to work together to make the player attack an enemy and make it lose health, and die. These are my two codes:

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("ApplyTheDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
        	}
    	}
    }
}

And the second is:

var Health = 100;

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

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

function Dead()
{
	Destroy (gameObject);
}

Thank you for reading this and trying to help me.

I too am new to the coding side of unity but looking through the code I think I’ve found your problem.

ORIGINAL -

hit.transform.SendMessage("ApplyTheDamage", TheDamage, SendMessageOptions.DontRequireReceiver);

Fix - hit.transform.SendMessage("ApplyTheDamage", ADD AMMOUNT OF HEALTH TO TAKE HERE);

I’m pretty sure this should work as I used something similar for my code. Please do tell me if it worked.