Help trying to instance..

Hi, I have my code here:

function RespawnPlayer () {
var line0 = transform.Find("line0");

var playerClone = Instantiate(newPlayer, line0.position, line0.rotation);
}

, but I try to call function, Console writes the error :

ps. Line 52 is the Instantiate event…

try this:

function RespawnPlayer () {
var line0 = transform.Find("line0");

var playerClone = Instantiate(newPlayer, line0.position, line0.identity);
}

Got solved for now, the problem was that i must to change trasnform.Find to GameObject.find … …thanks anyway… !

You do not have a child named “line0”; double check that it’s there and that the script is being called from the parent of “line0”.

EDIT: ahh found it I see. The distinction is that “transform.find” will find a child of that transform, whereas GameObject.Find will find any object in the scene, not just children. (though it can if you give it a hierarchy path)