I have been attempting to write a collection of scripts that deals with player health and an enemy object hitting a player object. This script is placed in a hitbox child of the enemy object and refers to a player health script which seems to be working correctly. When I approach the enemy however, Unity freezes up completely. I know that it is most likely some sort of loop or condition that is executing infinitely with little to no delay but I cannot seem to pinpoint exactly what it is. Most of the pieces of the script are modeled off of snippets of code that I have used before that worked so I am not quite sure exactly what the issue is. Any help would be appreciated. Here is the script.

#pragma strict

public var damageDone: float = 45f;
public var hitCoolDownTime: float = 1f;
public var meshObject: GameObject;

private var playerObject: GameObject;
private var playerHitBox: GameObject;
private var playerState: PlayerState;
private var hitCoolDown: boolean = false;
private var hitTimer: float = 0f;

//Crashes the game

function Awake () {
	playerObject = GameObject.FindGameObjectWithTag("Player");
	playerState = playerObject.GetComponent(PlayerState);
}

function Update () {
	if(hitCoolDown){
		hitTimer += Time.deltaTime;
		if(hitTimer >= hitCoolDownTime){
			hitCoolDown = false;
			hitTimer = 0f;
		}
	}
}

function OnTriggerEnter (other: Collider){
	if(other.gameObject == playerObject && !hitCoolDown && meshObject.GetComponent(SkinnedMeshRenderer).enabled){
		playerState.Damage(damageDone);
		hitCoolDown = true;
	}
}

Either meshObject or playerState is null.

I think so every time the trigger is entered the hitCoolDown = true and meanwhile in update every frame it gets updated and try
running your
if(hitCoolDown){
hitTimer += Time.deltaTime;
if(hitTimer >= hitCoolDownTime){
hitCoolDown = false;
hitTimer = 0f;
}
part of script which make an infinite loop and hangs your gameplay

I managed to fix my own issue by modifying the code inside the OnTriggerEnter so that the object that collides with the trigger is checked first, and then the cooldown and meshrenderer are checked in an if statement nested one level below.

function OnTriggerEnter (other: Collider){
	if(other.gameObject == playerHitBox){
		if(!hitCoolDown && meshObject.GetComponent(SkinnedMeshRenderer).enabled){
			playerState.Damage(damageDone);
			hitCoolDown = true;
		}
	}
}

I also all the trigger events occur in a separate layer because I have other colliders on both the enemy and the player than the ones I use here. Now everything works perfectly. Thank you all for all the help.