why doesnt my gui work correctly?

im sorry this looks like a mess, but what im trying to do is when i collect a coin a bar and part of it is lit. the when i collect another coin the previous gui will be hidden and the next next gui would be enabled. The problem im having is it glitches from where it needs to be to one of the previous ones.

May somebody please help me with a code or a tutorial on how to create this?

var LevelBar97 : GUITexture;
var LevelBar96 : GUITexture;
var LevelBar95 : GUITexture;
var LevelBar94 : GUITexture;
var LevelBar93 : GUITexture;
var LevelBar92 : GUITexture;
var LevelBar91 : GUITexture;
var LevelBar90 : GUITexture;
var LevelBar89 : GUITexture;
var LevelBar88 : GUITexture;
var LevelBar87 : GUITexture;
var LevelBar86 : GUITexture;
var LevelBar85 : GUITexture;
var LevelBar84 : GUITexture;
var LevelBar83 : GUITexture;
var LevelBar82 : GUITexture;
var LevelBar81 : GUITexture;
var LevelBar80 : GUITexture;
var LevelBar79 : GUITexture;
var LevelBar78 : GUITexture;
var LevelBar77 : GUITexture;
var LevelBar76 : GUITexture;
var LevelBar75 : GUITexture;
var LevelBar74 : GUITexture;
var LevelBar73 : GUITexture;
var LevelBar72 : GUITexture;
var LevelBar71 : GUITexture;
var LevelBar70 : GUITexture;
var LevelBar69 : GUITexture;
var LevelBar68 : GUITexture;
var LevelBar67 : GUITexture;
var LevelBar66 : GUITexture;
var LevelBar65 : GUITexture;
var LevelBar64 : GUITexture;
var LevelBar63 : GUITexture;
var LevelBar62 : GUITexture;
var LevelBar61 : GUITexture;
var LevelBar60 : GUITexture;
var LevelBar59 : GUITexture;
var LevelBar58 : GUITexture;
var LevelBar57 : GUITexture;
var LevelBar56 : GUITexture;
var LevelBar55 : GUITexture;
var LevelBar54 : GUITexture;
var LevelBar53 : GUITexture;
var LevelBar52 : GUITexture;
var LevelBar51 : GUITexture;
var LevelBar50 : GUITexture;
var LevelBar49 : GUITexture;
var LevelBar48 : GUITexture;
var LevelBar47 : GUITexture;
var LevelBar46 : GUITexture;
var LevelBar45 : GUITexture;
var LevelBar44 : GUITexture;
var LevelBar43 : GUITexture;
var LevelBar42 : GUITexture;
var LevelBar41 : GUITexture;
var LevelBar40 : GUITexture;
var LevelBar39 : GUITexture;
var LevelBar38 : GUITexture;
var LevelBar37 : GUITexture;
var LevelBar36 : GUITexture;
var LevelBar35 : GUITexture;
var LevelBar34 : GUITexture;
var LevelBar33 : GUITexture;
var LevelBar32 : GUITexture;
var LevelBar31 : GUITexture;
var LevelBar30 : GUITexture;
var LevelBar29 : GUITexture;
var LevelBar28 : GUITexture;
var LevelBar27 : GUITexture;
var LevelBar26 : GUITexture;
var LevelBar25 : GUITexture;
var LevelBar24 : GUITexture;
var LevelBar23 : GUITexture;
var LevelBar22 : GUITexture;
var LevelBar21 : GUITexture;
var LevelBar20 : GUITexture;
var LevelBar19 : GUITexture;
var LevelBar18 : GUITexture;
var LevelBar17 : GUITexture;
var LevelBar16 : GUITexture;
var LevelBar15 : GUITexture;
var LevelBar14 : GUITexture;
var LevelBar13 : GUITexture;
var LevelBar12 : GUITexture;
var LevelBar11 : GUITexture;
var LevelBar10 : GUITexture;
var LevelBar9 : GUITexture;
var LevelBar8 : GUITexture;
var LevelBar7 : GUITexture;
var LevelBar6 : GUITexture;
var LevelBar5 : GUITexture;
var LevelBar4 : GUITexture;
var LevelBar3 : GUITexture;
var LevelBar2 : GUITexture;
var LevelBar1 : GUITexture;


function Start () {



}

function Update () {




if (GameMain_Robots.coins == 1){
LevelBar100.enabled = false;
	LevelBar99.enabled = true;
	}
	
	
	if (GameMain_Robots.coins == 2){
LevelBar99.enabled = false;
	LevelBar98.enabled = true;
	}
	
		if (GameMain_Robots.coins == 3){
LevelBar98.enabled = false;
	LevelBar97.enabled = true;
	}
	
		if (GameMain_Robots.coins == 4){
LevelBar97.enabled = false;
	LevelBar96.enabled = true;
	}
	
		if (GameMain_Robots.coins == 5){
LevelBar96.enabled = false;
	LevelBar95.enabled = true;
	}
	
		if (GameMain_Robots.coins == 6){
LevelBar95.enabled = false;
	LevelBar94.enabled = true;
	}
	
		if (GameMain_Robots.coins == 7){
LevelBar94.enabled = false;
	LevelBar93.enabled = true;
	}
	
		if (GameMain_Robots.coins == 8){
LevelBar93.enabled = false;
	LevelBar92.enabled = true;
	}
	
		if (GameMain_Robots.coins == 9){
LevelBar92.enabled = false;
	LevelBar91.enabled = true;
	}
	
		if (GameMain_Robots.coins == 10){
LevelBar91.enabled = false;
	LevelBar90.enabled = true;
	}
		if (GameMain_Robots.coins==11){
		LevelBar90.enabled= false;
		LevelBar89.enabled = true;
	}
	
		if (GameMain_Robots.coins == 12){
LevelBar89.enabled = false;
	LevelBar88.enabled = true;
	}
	
		if (GameMain_Robots.coins == 13){
LevelBar88.enabled = false;
	LevelBar87.enabled = true;
	}
	
		if (GameMain_Robots.coins == 14){
LevelBar87.enabled = false;
	LevelBar86.enabled = true;
	}
	
		if (GameMain_Robots.coins == 15){
LevelBar86.enabled = false;
	LevelBar85.enabled = true;
	}
	
		if (GameMain_Robots.coins == 16){
LevelBar85.enabled = false;
	LevelBar84.enabled = true;
	}
	
		if (GameMain_Robots.coins == 17){
LevelBar84.enabled = false;
	LevelBar83.enabled = true;
	}
		if (GameMain_Robots.coins == 18){
LevelBar83.enabled = false;
	LevelBar82.enabled = true;
	}
		if (GameMain_Robots.coins == 19){
LevelBar82.enabled = false;
	LevelBar81.enabled = true;
	}
		if (GameMain_Robots.coins == 20){
LevelBar81.enabled = false;
	LevelBar80.enabled = true;
	}
		if (GameMain_Robots.coins == 21){
LevelBar80.enabled = false;
	LevelBar79.enabled = true;
	}
		if (GameMain_Robots.coins == 22){
LevelBar79.enabled = false;
	LevelBar78.enabled = true;
	}
		if (GameMain_Robots.coins == 23){
LevelBar78.enabled = false;
	LevelBar77.enabled = true;
	}
		if (GameMain_Robots.coins == 24){
LevelBar77.enabled = false;
	LevelBar76.enabled = true;
	}
		if (GameMain_Robots.coins == 25){
LevelBar76.enabled = false;
	LevelBar75.enabled = true;
	}
		if (GameMain_Robots.coins == 26){
LevelBar75.enabled = false;
	LevelBar74.enabled = true;
	}
		if (GameMain_Robots.coins == 27){
LevelBar74.enabled = false;
	LevelBar73.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 28){
LevelBar73.enabled = false;
	LevelBar72.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 29){
LevelBar72.enabled = false;
	LevelBar71.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 30){
LevelBar71.enabled = false;
	LevelBar70.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 31){
LevelBar70.enabled = false;
	LevelBar69.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 32){
LevelBar69.enabled = false;
	LevelBar68.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 33){
LevelBar68.enabled = false;
	LevelBar67.enabled = true;
	}
	
			if (GameMain_Robots.coins == 34){
LevelBar67.enabled = false;
	LevelBar66.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 35){
LevelBar66.enabled = false;
	LevelBar65.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 36){
LevelBar65.enabled = false;
	LevelBar64.enabled = true;
	}
	
			if (GameMain_Robots.coins == 37){
LevelBar64.enabled = false;
	LevelBar63.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 38){
LevelBar63.enabled = false;
	LevelBar62.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 39){
LevelBar62.enabled = false;
	LevelBar61.enabled = true;
	}
	
			if (GameMain_Robots.coins == 40){
LevelBar61.enabled = false;
	LevelBar60.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 41){
LevelBar60.enabled = false;
	LevelBar59.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 42){
LevelBar59.enabled = false;
	LevelBar58.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 43){
LevelBar58.enabled = false;
	LevelBar57.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 44){
LevelBar57.enabled = false;
	LevelBar56.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 45){
LevelBar56.enabled = false;
	LevelBar55.enabled = true;
	}
	
			if (GameMain_Robots.coins == 46){
LevelBar55.enabled = false;
	LevelBar54.enabled = true;
	}
	
			if (GameMain_Robots.coins == 47){
LevelBar54.enabled = false;
	LevelBar53.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 48){
LevelBar53.enabled = false;
	LevelBar52.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 49){
LevelBar52.enabled = false;
	LevelBar51.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 50){
LevelBar51.enabled = false;
	LevelBar50.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 51){
LevelBar50.enabled = false;
	LevelBar49.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 52){
LevelBar49.enabled = false;
	LevelBar48.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 53){
LevelBar48.enabled = false;
	LevelBar47.enabled = true;
	}
	
			if (GameMain_Robots.coins == 54){
LevelBar47.enabled = false;
	LevelBar46.enabled = true;
	}
	
			if (GameMain_Robots.coins == 55){
LevelBar46.enabled = false;
	LevelBar45.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 56){
LevelBar45.enabled = false;
	LevelBar44.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 57){
LevelBar44.enabled = false;
	LevelBar43.enabled = true;
	}
	
			if (GameMain_Robots.coins == 58){
LevelBar43.enabled = false;
	LevelBar42.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 59){
LevelBar42.enabled = false;
	LevelBar41.enabled = true;
	}
	
			if (GameMain_Robots.coins == 60){
LevelBar41.enabled = false;
	LevelBar40.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 61){
LevelBar40.enabled = false;
	LevelBar39.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 62){
LevelBar39.enabled = false;
	LevelBar38.enabled = true;
	}	
	
	if (GameMain_Robots.coins == 63){
LevelBar38.enabled = false;
	LevelBar37.enabled = true;
	}	if (GameMain_Robots.coins == 64){
LevelBar37.enabled = false;
	LevelBar36.enabled = true;
	}	if (GameMain_Robots.coins == 65){
LevelBar36.enabled = false;
	LevelBar35.enabled = true;
	}	if (GameMain_Robots.coins == 66){
LevelBar35.enabled = false;
	LevelBar34.enabled = true;
	}	if (GameMain_Robots.coins == 67){
LevelBar34.enabled = false;
	LevelBar33.enabled = true;
	}	if (GameMain_Robots.coins == 68){
LevelBar33.enabled = false;
	LevelBar32.enabled = true;
	}	if (GameMain_Robots.coins == 69){
LevelBar32.enabled = false;
	LevelBar31.enabled = true;
	}	if (GameMain_Robots.coins == 70){
LevelBar31.enabled = false;
	LevelBar30.enabled = true;
	}	if (GameMain_Robots.coins == 71){
LevelBar30.enabled = false;
	LevelBar29.enabled = true;
	}	if (GameMain_Robots.coins == 72){
LevelBar29.enabled = false;
	LevelBar28.enabled = true;
	}	if (GameMain_Robots.coins == 73){
LevelBar28.enabled = false;
	LevelBar27.enabled = true;
	}	if (GameMain_Robots.coins == 74){
LevelBar27.enabled = false;
	LevelBar26.enabled = true;
	}	if (GameMain_Robots.coins == 75){
LevelBar26.enabled = false;
	LevelBar25.enabled = true;
	}	if (GameMain_Robots.coins == 76){
LevelBar25.enabled = false;
	LevelBar24.enabled = true;
	}	if (GameMain_Robots.coins == 77){
LevelBar24.enabled = false;
	LevelBar23.enabled = true;
	}	if (GameMain_Robots.coins == 78){
LevelBar23.enabled = false;
	LevelBar22.enabled = true;
	}	if (GameMain_Robots.coins == 79){
LevelBar22.enabled = false;
	LevelBar21.enabled = true;
	}
	if (GameMain_Robots.coins == 80){
LevelBar21.enabled = false;
	LevelBar20.enabled = true;
	}if (GameMain_Robots.coins == 81){
LevelBar20.enabled = false;
	LevelBar19.enabled = true;
	}if (GameMain_Robots.coins == 82){
LevelBar19.enabled = false;
	LevelBar18.enabled = true;
	}if (GameMain_Robots.coins == 83){
LevelBar18.enabled = false;
	LevelBar17.enabled = true;
	}if (GameMain_Robots.coins == 84){
LevelBar17.enabled = false;
	LevelBar16.enabled = true;
	}if (GameMain_Robots.coins == 85){
LevelBar16.enabled = false;
	LevelBar15.enabled = true;
	}if (GameMain_Robots.coins == 86){
LevelBar15.enabled = false;
	LevelBar14.enabled = true;
	}if (GameMain_Robots.coins == 87){
LevelBar14.enabled = false;
	LevelBar13.enabled = true;
	}if (GameMain_Robots.coins == 88){
LevelBar13.enabled = false;
	LevelBar12.enabled = true;
	}if (GameMain_Robots.coins == 89){
LevelBar12.enabled = false;
	LevelBar11.enabled = true;
	}if (GameMain_Robots.coins == 90){
LevelBar11.enabled = false;
	LevelBar10.enabled = true;
	}if (GameMain_Robots.coins == 91){
LevelBar10.enabled = false;
	LevelBar9.enabled = true;
	}if (GameMain_Robots.coins == 92){
LevelBar9.enabled = false;
	LevelBar8.enabled = true;
	}if (GameMain_Robots.coins == 93){
LevelBar8.enabled = false;
	LevelBar7.enabled = true;
	}if (GameMain_Robots.coins == 94){
LevelBar7.enabled = false;
	LevelBar6.enabled = true;
	}if (GameMain_Robots.coins ==95){
LevelBar6.enabled = false;
	LevelBar5.enabled = true;
	}if (GameMain_Robots.coins == 96){
LevelBar5.enabled = false;
	LevelBar4.enabled = true;
	}if (GameMain_Robots.coins == 97){
LevelBar4.enabled = false;
	LevelBar3.enabled = true;
	}if (GameMain_Robots.coins == 98){
LevelBar3.enabled = false;
	LevelBar2.enabled = true;
	}if (GameMain_Robots.coins == 99){
LevelBar2.enabled = false;
	LevelBar1.enabled = true;
	}
	
	if (GameMain_Robots.coins == 100){
	LevelBar1.enabled = false;
	LevelBar100.enabled=true;
	
	}
	
	}

Firstly, I’d like to tell you that a million if statements like this is probably always a bad idea. If you really want to have separate GUITextures for each possible value of GameMain_Robots.coins, you’d be far better off placing them into an array and using value of GameMain_Robots.coins to calculate an index into it. Something like this:

#pragma strict

var levelBars : GUITexture[100];
var index = 100;

function Start () {

}

function Update () {
	var oldIndex = index;
	index = levelBars.length - GameMain_Robot.coins;
	if (index != oldIndex) {
		levelBars[oldIndex].enabled = false;
		levelBars[index].enabled = true;
	}
}

Secondly, I think the problem you were experiencing was caused by the fact that your code only accounts for GameMain_Robot.coins increasing by 1 everytime. If its value does anything besides increase by 1 your code breaks.

check to see if you need the function start() in that script it may be getting in the way. disclaimer. this may be wrong
after collecting the 63rd coin your spacing is off mabey fixing that will help.