GUI Button Disappears

Hello, I’m trying to make left and right GUI buttons for my character. But when ever the left button is pressed, the right button disappears. The right button works correctly.

I figure it’s because once the left button conditional statement is started, the if statement that shows the right is no longer activated. Any combination of if/else if statements don’t seem to work.

Here’s my code:

`
var theMainCharacter : GameObject;

function OnGUI () {

if (GUI.RepeatButton(Rect (0,Screen.height - 50,100,50), "Left")) {
	theMainCharacter.animation.CrossFade ("walk");
}
else{
	if (GUI.RepeatButton(Rect (100,Screen.height-50,100,50), "Right")) {
		theMainCharacter.animation.CrossFade ("walk");
	}
	else{
		theMainCharacter.animation.CrossFade ("idle");
	}
		
	}
}

`

Solved it on my own!

I just seperated the if statement from the one that creates the object:

`
var theMainCharacter : GameObject;

function OnGUI () {

var leftButton = GUI.RepeatButton(Rect (0,Screen.height - 50,100,50), "Left");
var rightButton = GUI.RepeatButton(Rect (100,Screen.height-50,100,50), "Right");

if (leftButton) {
	theMainCharacter.animation.CrossFade ("walk");
}
else if (rightButton) {
	theMainCharacter.animation.CrossFade ("walk");
}
else{
	theMainCharacter.animation.CrossFade ("idle");
}

}

`