well i made this code folowing a FPS multiplayer tutorial and i cant get whay its now working!!! so if anyone know whay please tell me. an as fast as posiabel awnser whould be preferabel.
C#
using UnityEngine;
using System.Collections;


public class shoting : MonoBehaviour {


public float fierRate = 0.5f;
float cooldown = 0f;
public float damage = 25f;



// Update is called once per frame
void Update () {
cooldown -= Time.deltaTime;
if (Input.GetButton ("fire1")) {
fier();

}
}
void fier() {
if (cooldown > 0) {
return;

}


Ray ray = new Ray (Camera.main.transform.position, Camera.main.transform.forward);
Transform hitTransform;




hitTransform = FindClosestHitObject(ray);
if (hitTransform != null) {


helth h = hitTransform.GetComponent<helth>();


while(h == null && hitTransform.parent){
hitTransform = hitTransform.parent;
 h = hitTransform.GetComponent<helth>();


}


if(h != null){


h.takedamage( damage );
}
}
cooldown = fierRate;
}
Transform FindClosestHitObject(Ray ray) {
RaycastHit[] hits = Physics.RaycastAll(ray);
Transform closestHit = null;


float distance = 0;


foreach (RaycastHit hit in hits) {
if(hit.transform != this.transform && ( closestHit==null || hit.distance < distance ) ){


closestHit = hit.transform;
distance = hit.distance;


}
}


}

}