Timer randomly freezes and will not restart.

So, I wasn’t having the problem earlier… It was when I went to the top to set up a build to share it with a friend that it started nulling out, since then I had to re-apply all of my scripts etc to get it to work.

It will always finish off the first NPC, then will sometimes finish the second one… After that it freezes. If I rightclick on the target sometimes it does damage once, but does not continue… Then it’s a pain to get it to do another damage calculation, have to click all over the place, back onto the target… it’s really just luck if you get to do damage gaain

Here is my Code, perhaps you guys can help me
using UnityEngine;
using System.Collections;

public class AttackHandler : MonoBehaviour {
    float attackDelay = 1.0f;
	float nextDamageEvent;
	float distance;
	public bool attacking;
	AudioClip basicMelee;

	Transform target;
	RaycastTargetting rct;
	NPCHealthHandler npch;
	StatHandler sh;
	void Start () {
		rct = GetComponent<RaycastTargetting>();
		sh = GetComponent<StatHandler>();
		attacking = false;
	}
	
	// Update is called once per frame
		void Update() {
			if(Input.GetMouseButtonUp(1)) {
				RaycastHit hit;
	            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	            if (Physics.Raycast (ray, out hit, 250))
	            {
					Debug.Log ("Hit: " +hit.transform.tag);
	                if (hit.transform.tag == "NPC")
	                {
						attacking = true;
					}
				}
			}
				if(rct.target != null) {
						if(attacking) {
				        	if (inRange()) {
				        		if (Time.time >= nextDamageEvent) {
				            		nextDamageEvent = Time.time + attackDelay;
									attackTarget();
				        		}
							} else { 
						nextDamageEvent = Time.time + attackDelay;
					}
				}
					
			}
		}
		
	bool inRange() {
		distance =  Vector3.Distance(transform.position, rct.target.position);
		if(distance < 6.0f) 
			return true;
		return false;
	}	
	
	public void DebugDistance() {
		distance = Vector3.Distance(transform.position, rct.target.position);
		Debug.Log (distance);
	}
	int i = 0;
	
	void attackTarget() {
		audio.PlayOneShot(basicMelee);
		npch = rct.target.GetComponent<NPCHealthHandler>();
		npch.NPC_currHealth -= damage();
	}
	
	
	int strength;
	float strengthModifier;
	int weaponDamage;
	
	public int damage() {
		strength = sh.strength;
		strengthModifier = 0.6f;
		weaponDamage = 10; //Set this to EquipmentManager.weaponDamage
		
		return (int)(strength * strengthModifier) + weaponDamage;	
	}
}

Editing for a bump, still need help.
EDIT#2 : Still in need of help
EDIT#3: Still cant get it
Edit:4: This is getting really annoying, the lack of help is really upsetting.

I think I may have spot a problem with your code], I suspect that the error may come from your void Update()

if(Input.GetMouseButtonUp(1)) {
   RaycastHit hit;
   Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
   if (Physics.Raycast (ray, out hit, 250))
   {
      Debug.Log ("Hit: " +hit.transform.tag);
      if (hit.transform.tag == "NPC")
      {
         attacking = true;
      }
   }
}
if(rct.target != null) {
   if(attacking) // Attacking is always true after the first hit!!
   {
      if (inRange()) 
      {
         if (Time.time >= nextDamageEvent) 
         {
            nextDamageEvent = Time.time + attackDelay;
            attackTarget();
         }
      } 
      else 
      { 
         nextDamageEvent = Time.time + attackDelay;
      }
   }
}

When you first hit a NPC, attacking become true, but you never set it back to false. So what happens after the first hit is, whenever rct.target != null, you will always go to the if(attacking) because attacking is never false.

Then if InRange() is false, you reset your nextDamageEvent, this will affect your if(Time.time >= nextDamageEvent), because whenever you are not inRange() with your target, you need to wait again for the next shot.

What you want from your code:
When I click attack, I attack the NPC if NPC is in range, else I missed. After an attack (whether it lands or not), I will need to wait.

What you current have:
I have to be inRange() with the NPC for a specific time then I will attack them right away, if I am not inRange() for a split second, I will have to wait again

To fix this, you just have to put in attacking = false; at the start of your Update().

P/S: This may not be correct, but I don’t see any problem with the other parts of your code, and I also assume that the problem did not originated from your RaycastTargetting