Gui keyboard selection script (Help)

I have followed a tutorial for creating a character selection screen, so far everything works for that but i decided to create a Main menu to select game modes and exit the game.

the script i have all together for it is as follows, but i will post the area where i am having trouble

Edit: last comment i made says it, but ill put it up here as well, resolved the issue for one selection, but now it is saying i have an EOF of “Else” which does not make to much sense, trying to figure it out, commenting them out (the last 3 selections) works fine, so i think i have an extra {} somewhere in my code.

var guiskin : GUISkin;

enum CurrentFocus2 {button1=1, button2=2, button3=3, button4=4}
private var currentFocus2 : CurrentFocus = CurrentFocus.button1;

private var selectSeq : boolean;

var guiStyles : String[];

function Awake(){
	Screen.lockCursor = true;  //Locks out mouse (use Escape to bring back tempory)
}


function Update () 
{
	if (Input.GetKeyDown("space")){
		SelectCharacter();
	}
	
	if (Input.GetKeyDown (KeyCode.Escape)){
			Application.Quit();}

	switch (currentFocus2){
		case 1:
			if(Input.GetKeyDown(KeyCode.UpArrow)){
				currentFocus2 = 4;}
				else if (Input.GetKeyDown(KeyCode.DownArrow)){
				currentFocus2 = 2;}
		break;
		
		case 2:
			if(Input.GetKeyDown(KeyCode.UpArrow)){
				currentFocus2 = 1;}
				else if (Input.GetKeyDown(KeyCode.DownArrow)){
				currentFocus2 = 3;}
		break;
		
		case 3:
			if(Input.GetKeyDown(KeyCode.UpArrow)){
				currentFocus2 = 2;}
				else if (Input.GetKeyDown(KeyCode.DownArrow)){
				currentFocus2 = 4;}
		break;
		
		case 4:
			if(Input.GetKeyDown(KeyCode.UpArrow)){
				currentFocus2 = 3;}
				else if (Input.GetKeyDown(KeyCode.DownArrow)){
				currentFocus2 = 1;}
		break;
		
	}
	
}


function OnGUI () {
	GUI.skin = guiskin; //Will organize script later
	
	GUI.SetNextControlName("button1");
	GUI.Button(Rect(500,200,150,75), "", guiStyles[1]); //Character 1
	
	GUI.SetNextControlName("button2");
	GUI.Button(Rect(500,300,150,75), "", guiStyles[2]); //Character 2
	
	GUI.SetNextControlName("button3");
	GUI.Button(Rect(500,400,150,75), "", guiStyles[3]); //Character 3
	
	GUI.SetNextControlName("button4");
	GUI.Button(Rect(500,500,150,75), "", guiStyles[4]); //Character 4
	
	
	switch (currentFocus2) {
		case 1:
			GUI.FocusControl("button1");
			break;
		case 2:
			GUI.FocusControl("button2");
			break;
		case 3:
			GUI.FocusControl("button3");
			break;
		case 4:
			GUI.FocusControl("button4");
			break;
			}
}

function SelectCharacter() {
	selectSeq = true;
	guiStyles[currentFocus2] = guiStyles[currentFocus2].ToString() + "_2";
	yield WaitForSeconds(0.1);
	guiStyles[currentFocus2] = currentFocus2.ToString();
	yield WaitForSeconds(1.0);

if (guiStyles[currentFocus2] == guiStyles[1]); 
	{Application.LoadLevel("Character_Select");}
     
   else if (guiStyles[currentFocus2] == guiStyles[2]); 
   	{Application.LoadLevel("Character_Select");}
    
	 else if (guiStyles[currentFocus2] == guiStyles[3]); 
	 	{Application.LoadLevel("Options_Menu");}
     
		else if (guiStyles[currentFocus] == guiStyles[4]);
		{Application.Quit();}
		
		}

You forgot to use the () in your if statements. Also if you want to compare values you have to use the == operator !!!

if (guiStyles[currentFocus] == guiStyles[1]) {
Application.LoadLevel("Character_Select");}

else if (guiStyles[currentFocus] == guiStyles[2]) {
Application.LoadLevel("Character_Select");}

else if (guiStyles[currentFocus] == guiStyles[3]) {
Application.LoadLevel("Options_Menu");}

else if (guiStyles[currentFocus] == guiStyles[4]){
Application.Quit();}

And a quick tip: If you post your code in CODE tags it is much easier to read :wink:

Edit: everything has been said already :stuck_out_tongue:

Ok that worked out, but i am getting an EOF and an expecting a } before the 2nd else if statement, if i comment it all out, the first selection works fine, but when i uncomment the second one to progress i get the same errors, somehow i feel i typed too fast when i was coding it now, but i am looking into what i need to add to fix this

If your’re looking on you code you see that you put a ; at the end of each if, else if statement (line 97, 100, 103 , 106). This is an error.

It seems that you’re not very experienced in the porgramming language. Maybe you should work first a little bit more on the basics.

I do more 3d artwork than i do programming, however my friends who want to work on a project have no experience what so ever with game development and sort of threw this on my two nights ago, from a crash course in scripting it’s not bad but honestly if i had the chance i’d rather finish CodeAcademy like i was previously doing.

Thank you for the help though Thoeppner and willemsenzo.

Hope your code works now.

But I honestly advise you to learn first the language itself. Otherwise you will spend so much time to find errors you won’t make when you have the right knowledge.