Instantiate prefab problem...

Here’s the error I get with the code below. I’ve dragged the prefab from the Project view (Its on in the Scene or Hierarchy views) and the script shows that it’s referenced in the inspector properly (I’m pretty good at knowing how to do this sort of thing)… any ideas? Should the prefab be a public var or static or something? It’s quite a complex prefab with a skier that I want to ragdoll…

UnassignedReferenceException: The variable prefab of ‘HealthBar’ has not been assigned.
You probably need to assign the prefab variable of the HealthBar script in the inspector.

var Health : float = 100;
var HealthBar : Transform;
var prefab : Transform;

function Update(){
	HealthBar.renderer.material.color.r = 1-(Health/100) ;
	HealthBar.renderer.material.color.g = Health/100 ;
	HealthBar.localScale = Vector3(0.01,0.03,Health/500);
}



function OnCollisionEnter(collision : Collision) {
	if (collision.relativeVelocity.magnitude > 2)Health-=10;
	Instantiate (prefab, this.transform.position, this.transform.rotation);
	Destroy (this.gameObject);
}

OK, I’m sorry - I found a 2nd reference to this HealthBar script, which I deleted, and the error is gone. Now the only issue is that the health bar is not reducing in size upon collision, nor is the ragdoll actually ragdolling… anyone got any insights for this noob coder? :slight_smile: