Parenting problem

Hi guys I’m trying to instantiate an object with a parent to a point of view but i get null reference. Here is the code:

var showMessage : boolean;
var someMessage : String;
var prefab : Transform;
var pov : GameObject;

private var video : GameObject;

function OnGUI(){
        GUI.Box(Rect(Screen.width/2,Screen.height/2, 100, 25),someMessage);

function OnTriggerEnter(){
    showMessage = true;

function OnTriggerExit(){
    showMessage = false;

function videostart() {
    video = Instantiate(prefab, pov.position, pov.rotation) as GameObject;
    video.transform.parent = pov.transform;

When you get a null reference error, the error will be said to have happened at a particular source line. When posting these questions, always identify which source line in the script code Unity has detected the error upon. Also, have a practice with “code” formatting in the posts.

Assuming that the error occurs at the Instantiate line then either:

  1. prefab is null
  2. pov is null

Check, check and double check that these publicly exported variables have values.