Meele System problem

for some reason my melee system won’t work it’s using raycasts and I did everything right where i make a empty gameobject on the main camera on the player but still nothing.
please help me asap! Thx

ALSO WHOEVER GETS IT RIGHT WILL GET A COPY OF THE GAME WHEN FINISHED

#pragma strict

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

function Update ()
{
	if (Input.GetButtonDown("Fire1")) 
	{
		
		//GetComponent.<Animation>().Play("Attack");

	}

}

function AttackDammage ()
{
		//Attack function
		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);
			}
		}
}

I can see that we learned raycast from the same person, but anyways try this instead:

()

function Update ()
 {
     if (Input.GetButtonDown("Fire1")) 
     {
         GetComponent.<Animation>().Play("Attack");
     }
 
 }
 
 function AttackDammage ()
 {
 	if (Physics.Raycast (ray, hit, 1.5f)) // 1.5f = the lenght of the raycast
		{
			hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
		}
 }

I shall work with you through this, but I need to know what kind of errors you’re encountering, do you know if the raycast is hitting the enemy for sure? Or is it a problem with sending the applydamage function to the enemy? Try this cleaner code aswell.

var TheDammage : int = 50;
 var Distance : float;
 var MaxDistance : float = 1.5;
 var TheSystem : Transform;
 
 function Update ()
 {
     if (Input.GetButtonDown("Fire1")) 
     {
         
          print("Pressed Button");
          AttackDamage();
         //GetComponent.<Animation>().Play("Attack");
 
     }
 
 }
 
 function AttackDammage ()
 {
        
             print("Attack Damage Was Called");
         //Attack function
         var hit : RaycastHit;
         if (Physics.Raycast (TheSystem.transform.position, TheSystem.transform.forward, hit))
         {
             print("Hit Something");
             Distance = hit.distance;
             if (Distance < MaxDistance)
             {
                 hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
             print("Should've Applied Damage");
             }
         }
 }