Help me.Prefab error in Runtime

i want “monster” hp <= 0 Destroy(this.gameObject); And Returned to its original use Prefab . first try is ok but second try is error

Thank you

9338-error.jpg

My Code Java_Scrip [MonsterDie_left]
#pragma strict
var hp:int=3;
var monster:Transform;

function Start () {

}

function Update ()
{

}

function OnCollisionEnter (collision:Collision)

{
if(collision.gameObject.tag =="bullet")
{ hp -=1; 
Destroy(collision.gameObject);}

if(collision.gameObject.tag =="gameover")
{ 
yield WaitForSeconds(3);
transform.position.x= -0.514125;
transform.position.y= 0.300876;
transform.position.z= 1.4806; 
}

if (hp < 1 )
{
Destroy(this.gameObject);

Instantiate (monster,Vector3(-0.514125,0.300876,1.4806),transform.rotation); 
}

}

1 Answer

1

Have you assigned the variable MonsterDie_left in the inspector the way that the error message tells you? Perhaps that is something to do with a script on the monster that you are instantiating…