UnassignedReferenceException

I am a complete newbie when it comes to scripting/programming. I am following along to a tutorial to make a matching tile game.

This is the error that I keep getting

UnassignedReferenceException: The variable matchTwo of ‘TileGenerator’ has not been assigned.
You probably need to assign the matchTwo variable of the TileGenerator script in the inspector.
TileGenerator.revealCardTwo () (at Assets/Assets/Scripts/TileGenerator.js:80)
TileGenerator.Update () (at Assets/Assets/Scripts/TileGenerator.js:50)

This is the code

var hit : RaycastHit;
var numberOfTiles = 16;
var tileLocations = new Array ( //Array to hold the tiles
Vector3 (0,0,0), Vector3 (1.5,0,0),
Vector3 (3,0,0), Vector3 (4.5,0,0),
Vector3 (0,1.5,0), Vector3 (1.5,1.5,0),
Vector3 (3,1.5,0), Vector3 (4.5,1.5,0),
Vector3 (0,3,0), Vector3 (1.5,3,0),
Vector3 (3,3,0), Vector3 (4.5,3,0),
Vector3 (0,4.5,0), Vector3 (1.5,4.5,0),
Vector3 (3,4.5,0), Vector3 (4.5,4.5,0));
var matchOne : GameObject;
var tileObjects : GameObject [];
var tileName1 : String;
var tName1 : Array; //creates an array to hold the names of the cards to be called
var matchTwo : GameObject;
var tileName2 : String;
var tName2 : Array;

function Start () 
{

	Camera.main.transform.position = Vector3 (2.25,2.25, -8);
		for ( var i = 0; i < numberOfTiles; i++) // places tiles in grid increasing them until it reaches 16
	
		{
			Instantiate (tileObjects_, tileLocations*, Quaternion.identity); //*_

* }*

}

function Update ()

* {*
* if (Input.GetButtonDown(“Fire1”)) //checks if the mouse button has been pressed.*
* var ray1 = Camera.main.ScreenPointToRay(Input.mousePosition); //used to send ray from camera position*
* {*
* //print (“Mouse Clicked”);*
* }*
* {*
* if (Physics.Raycast(ray1, hit, Mathf.Infinity)) //checks to see if object was hit with the ray*
* {*
* //print (“Help me bob I’ve hit something”);*
* if (!matchOne)*
* {*
* revealCardOne ();*
* }*
* else*
* {*
* revealCardTwo ();*
* }*

* }*
* } *
* } *

function revealCardOne () //reveal card
* {*
* matchOne = hit.transform.gameObject; //reveals card is it has been clicked*
* tileName1 = matchOne.transform.parent.name;//checks name of the parent object name to allow comparison*
* (print(tileName1));*
* if (matchOne == null)*
* {*
* //print (“No object found”);*
* }*

* else*
* {*
* tName1 = tileName1.Split (“_”[0]); //places the clones of the tileobjects into array and splits them into substrings*
* matchOne.transform.Rotate (Vector3(0,180,0));*
* }*
* {*
* //print (“tName1[0]”);*
* }*
* }*

function revealCardTwo ()
* {*
* matchOne = hit.transform.gameObject; //reveals card is it has been clicked*
* tileName2 = matchTwo.transform.parent.name;//checks name of the parent object name to allow comparison*
* (print(tileName2));*
* if (matchTwo == null)*
* {*
* //print (“No object found”);*
* }*

* else*
* {*
* tName2 = tileName2.Split (“_”[0]); //places the clones of the tileobjects into array and splits them into substrings*
* //print (“tName2[0]”);*

* matchTwo.transform.Rotate (Vector3(0,180,0));*
* }*

* }*

I am aware it is telling me to assign the matchTwo var in the inspector, I shouldn’t have to assign it in the inspector. So I declared the matchOne and matchTwo vars as private. This is the error I get when doing that.
Assets/Assets/Scripts/TileGenerator.js(15,29): UCE0001: ‘;’ expected. Insert a semicolon at the end.
I don’t understand as to why I am getting this error as there is a semi colon at the end of the line. Here is the code
#pragma strict

var hit : RaycastHit;
var numberOfTiles = 16;
var tileLocations = new Array ( //Array to hold the tiles
Vector3 (0,0,0), Vector3 (1.5,0,0),
Vector3 (3,0,0), Vector3 (4.5,0,0),
Vector3 (0,1.5,0), Vector3 (1.5,1.5,0),
Vector3 (3,1.5,0), Vector3 (4.5,1.5,0),
Vector3 (0,3,0), Vector3 (1.5,3,0),
Vector3 (3,3,0), Vector3 (4.5,3,0),
Vector3 (0,4.5,0), Vector3 (1.5,4.5,0),
Vector3 (3,4.5,0), Vector3 (4.5,4.5,0));
private var matchOne : GameObject;
var tileObjects = GameObject [];
var tileName1 : String;
var tName1 : Array; //creates an array to hold the names of the cards to be called
private var matchTwo : GameObject;
var tileName2 : String;
var tName2 : Array;

function Start ()
{

* Camera.main.transform.position = Vector3 (2.25,2.25, -8);*
* for ( var i = 0; i < numberOfTiles; i++) // places tiles in grid increasing them until it reaches 16*

* {*
Instantiate (tileObjects_, tileLocations*, Quaternion.identity); //
}*_

}

function Update ()

* {*
* if (Input.GetButtonDown(“Fire1”)) //checks if the mouse button has been pressed.*
* var ray1 = Camera.main.ScreenPointToRay(Input.mousePosition); //used to send ray from camera position*
* {*
* //print (“Mouse Clicked”);*
* }*
* {*
* if (Physics.Raycast(ray1, hit, Mathf.Infinity)) //checks to see if object was hit with the ray*
* {*
* //print (“Help me bob I’ve hit something”);*
* if (!matchOne)*
* {*
* revealCardOne ();*
* }*
* else*
* {*
* revealCardTwo ();*
* }*

* }*
* } *
* } *

function revealCardOne () //reveal card
* {*
* matchOne = hit.transform.gameObject; //reveals card is it has been clicked*
* tileName1 = matchOne.transform.parent.name;//checks name of the parent object name to allow comparison*
* (print(tileName1));*
* if (matchOne == null)*
* {*
* //print (“No object found”);*
* }*

* else*
* {*
* tName1 = tileName1.Split (""[0]); //places the clones of the tileobjects into array and splits them into substrings*
* matchOne.transform.Rotate (Vector3(0,180,0));
}
{
//print (“tName1[0]”);
}
}*_

function revealCardTwo ()
* {*
* matchOne = hit.transform.gameObject; //reveals card is it has been clicked*
* tileName2 = matchTwo.transform.parent.name;//checks name of the parent object name to allow comparison*
* (print(tileName2));*
* if (matchTwo == null)*
* {*
* //print (“No object found”);*
* }*

* else*
* {*
* tName2 = tileName2.Split (""[0]); //places the clones of the tileobjects into array and splits them into substrings*
* //print (“tName2[0]”);*_

* matchTwo.transform.Rotate (Vector3(0,180,0));*
* }*

* }*

Any help would be greatly appreciated. Thank you.

You cannot get information from a object referred to by a null reference regardless if it is public or private. Nowhere in your code do you assign a value to ‘matchTwo’, so unless it is assigned in the Inspector, the following (line 80 in your first script) will generate an error:

tileName2 = matchTwo.transform.parent.name;//checks name of the parent object name to allow comparison.

As for making it private, that will not solve your problem, since nothing assigns a value to matchTwo. But the error has nothing to do with making it private. The error is in this line:

var tileObjects = GameObject [];

…which should be:

var tileObjects : GameObject[];