How to make third person melee combat?

here is the script:

#pragma strict

var TheDammage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var TheSystem : Transform;

function Update ()
{
	if (Input.GetButtonDown("Fire1")) 
	{
		animation.Play("attacker");
    }
}

function AttackDammage ()
{
		var hit : RaycastHit;
		if (Physics.Raycast (TheSystem.transform.position, TheSystem.transform.TransformDirection(Vector3.forward), hit))
		{
			Distance = hit.distance;
			if (Distance < MaxDistance)
			{
				hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
			}
		}
}

the animation does not fully play(because when i click the “idle” animation stops it from completing)and it does not do any damage to an enemy.
so if you could show me how to fix it, i will be thankful :slight_smile:

Shouldn’t you insert
AttackDamage();
After line 12 ? How are you exactly accessing he AttackDamage() function to show damage ?

Red.