I'm new to coding. BCE0044 error. How do I fix? When I delete the extra } it gives me 23 errors

var cols:int = 4;
var rows:int = 4;
var totalCards:int = 16;
var matchesNeededToWin:int = totalCards * 0.5;
var matchesMade:int = 0;
var cardW:int = 100;
var cardH:int = 100;
var aCards:Array;
var aGrid:Array;
var aCardsFlipped:ArrayList;
var playerCanClick:boolean;
var playerHasWon:boolean = false;

function Start() 
{
	playerCanClick = true;
	aCards = new Array();
	aGrid = new Array();
	aCardsFlipped = new ArrayList();
	for(i=0; i<rows; i++)
	{
	aGrid *= new Array();*
  • for(j=0; j<cols; j++)*
  • {*
    _ aGrid*[j] = new Card();_
    _
    }_
    _
    }_
    _
    }*_

function BuildGrid()
{
* GUILayout.BeginVertical();*
* for(i=0; i<rows; i++)*
* {*
* GUILayout.BeginHorizontal();*
* for(j=0; j<cols; j++)*
* //}*

* {*
_ var card:Object = aGrid*[j];
if(GUILayout.Button(Resources.Load(card.img), GUILayout.Width(cardW)))
//}*_

* {*
* Debug.Log(card.img);*
* }*
* }*
* GUILayout.EndHorizontal();*
* }*
* GUILayout.EndVertical();*
* }*
* }*

function OnGUI()
{
* GUILayout.BeginArea (Rect(0,0,Screen.width,Screen.height));*
* BuildGrid();*
* GUILayout.EndArea();*
* print(“building grid!”);*
}

class Card extends System.Object
* {*
* var isFaceUp:boolean = false;*
* var isMatched:boolean = false;*
* var img:String;*
* function Card()*
* {*
* img = “robot”;*
* }*
* }*

I can go ahead and tell that you are working out of one of the Unity books (One that I remember doing in one of my past classes in college)

If I am not mistaken, this is a snippet of code from the “Robot Repair” chapters.

The finished code is in the book

I recommend you sit down with the book, and make sure you have it typed out exactly the same way he typed it.

He gives step by step instructions on how to set it up.

Read slow, and make sure to do everything he does in the book

Proof: I went through the book and completed this very project

Remove the extra }

and add “var” infront of the variable in the forloops

 for(var i=0; i < rows; i++)
    {
		aGrid *= new Array();*
  •  for(var j=0; j < cols; j++)*
    
  •  {*
    

_ aGrid*[j] = new Card();_
_
}_
_
}*_

you got a redundant } in line 51 delete it save and it will work

and in a for loop you should add var.

just replace your start and BuildGrid functions with that:

function Start() 
{
    playerCanClick = true;
    aCards = new Array();
    aGrid = new Array();
    aCardsFlipped = new ArrayList();
    for(var i=0; i<rows; i++)
    {
        aGrid *= new Array();*

for(var j=0; j<cols; j++)
{
aGrid*[j] = new Card();*
}
}
}

function BuildGrid()
{
GUILayout.BeginVertical();
for(var i=0; i<rows; i++)
{
GUILayout.BeginHorizontal();
for(var j=0; j<cols; j++)
{
var card:Object = aGrid*[j];*
if(GUILayout.Button(Resources.Load(card.img), GUILayout.Width(cardW)))
{
Debug.Log(card.img);
}
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}
and a tip for the new developer :
if you got more errors after fixing an error it doesn’t mean that you did something wrong
when the program(its called compiler) is trying to run your code it does several checks
on your code so if you got wrong parentheses placement the compiler won’t check your code any further (so after you fix it it will do more checks on your code and find more errors if there are any)
parentheses checks are one of the the first ones so if you don’t see them than they are usually fine
good luck with the new hobby :slight_smile: