Field 'UnityEngine.GameObject.name' not found

In my player collision script I created public variable to represented the prefab of the matches.

var matchGUI : GameObject;

I then went to the unity and drag the prefab to the variable…

When the collision execute… all line executed except

matchGUIobj.name = matchGUI;
and the error below show up in the unity …

MissingFieldException: Field ‘UnityEngine.GameObject.name’ not found.

if (collisionInfo.gameObject.tag == "matchbox")
	{
		Destroy(collisionInfo.gameObject);
		haveMatches = true;
		audio.PlayOneShot (batteryCollect);
		var matchGUIobj = Instantiate(matchGUI, Vector3(0.15,0.1,0),
		transform.rotation);
		matchGUIobj.name = matchGUI;
		
		
	}

What am I missing ?

The error message isn’t very helpful, but you appear to be trying to assign a GameObject to a string with that line. The error goes away if you change it to:-

matchGUIobj.name = matchGUI.name;

or try:

matchGUIobj.name = “matchGUI”;