You should format your code using the 101010 button.
After doing this I found some brackets in odd places, moved these and saved into my project with no errors. Weather it does exactly what you want it to do is a different matter and a different question…
Here is your code, reformatted and potentially fixed :
#pragma strict
var TheDamage : int = 50;
var Distance : float;
function Update() {
if (Input.GetButtonDown("Fire!")) {
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit)) {
Distance = hit.distance;
hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}