This is my script, but the raycast only damages the ai every click, i want it to damage the ai even when i hold down the left mouse button:
function Update(){
if(Input.GetMouseButtonDown(0)){ // if the Left button pressed
// casts a ray from the mouse pointer
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;
if(Physics.Raycast(ray, hit)){ // if something hit, send the message
hit.collider.SendMessageUpwards("ApplyDamage", 20, SendMessageOptions.DontRequireReceiver);
}
}
}