Add Player as Child of Camera in next Scene

Hi , I want add Player as child of MainCamera in next Scene .

Here is the script .

 public var target : Transform;

function StartGame (level : String) {
DontDestroyOnLoad (target.gameObject);
target.rigidbody.useGravity = false;

Application.LoadLevel(level);
}
  function OnLevelWasLoaded()
{         
     target.transform.parent = Camera.mainCamera.transform;
}

You’re just declaring the target variable without assigning a value to it.
You’ll have to assign the transform component to your target variable.
target = this.transform;

thanks , but thisnt problem !

Well, you didn’t described the problem. :slight_smile:

the problem is in next Scene dosent add target addet to inspector