UnassignedReferenceException

private var ray : Ray;

private var rayCastHit : RaycastHit;

var highScore3DText :TextMesh;

function Awake()
{

highScore3DText.text = “High Score:” + PlayerPrefs.GetInt(“highScore”).ToString();
}

function Update ()
{

if(Input.GetMouseButtonDown(0))
{

ray = Camera.main.ScreenPointToRay(Input.mousePosition);

if(Physics.Raycast (ray, rayCastHit))
{

if (rayCastHit.transform.name == “PlayButton”)
{

Application.LoadLevel("MainGame");

}
}
}
}

error at line highScore3DText.text = “High Score:” + PlayerPrefs.GetInt(“highScore”).ToString(); }

The error is just like how it sounds: “UnassignedReferenceException”. rayCastHit’s transform is null, so it has no name. It can’t compare because it doesn’t exist. You’re going to have to find an alternative method. Look around the forums/answers, I found this quickly without much trouble: Get Name From Raycast or to simply remove error, at line 9 add: if (rayCastHit.transform != null)

You did not assign something to the highScore3DText?