expecting } found " when there is no " ?

[952-Screen+shot+2012-05-18+at+14.31.04.png|952]

if any one could give me information on what is wrong with this script then your help would be appreciated

I see more problems than the missing “}”. You declared your texture variables inside Update, so they will loose what ever they contain each frame (actually they aren’t even initialized). Like MDReptile said, you should format your code. There are a lot common rules on how to format code. You should not use them all, that’s not possible since there are different styles, but pick at least one of them and keep this style in all of your scripts.

All errors i’ve found:

  • first line you need a colon (:slight_smile: instead of a semicolon(:wink: between the variable name and the type
  • Like already mentioned, the texture variables should be declared outside of the Update function. They need to be part of your class / script.
  • In line 14 you set charge to 0 and right after you do an if else chain on the charge variable which is useless since it’s always 0
  • You enable the guiTexture also unconditional each frame in line 13, but you set it to true again in line 19 which is also useless.
  • Since you didn’t follw any indention rule you messed up your opening and closing brackets

I guess it should look like this:

static var charge : int = 0;

var charge1Tex : Texture2D;
var charge2Tex : Texture2D;
var charge3Tex : Texture2D;
var charge4Tex : Texture2D;
var charge0Tex : Texture2D;

function Update()
{
    guiTexture.enabled = true;
    if(charge == 1)
    {
        guiTexture.texture = charge1Tex;
    }
    else if(charge == 2)
    {
        guiTexture.texture = charge2Tex;
    }
    else if(charge == 3)
    {
        guiTexture.texture = charge3Tex;
    }
    else if(charge >= 4)
    {
        guiTexture.texture = charge4Tex;
    }
    else
    {
        guiTexture.texture = charge0Tex;
    }
}

Since the charge variable is static, i guess you want to set it from another script.

I dunno if you will ever return to read any of this :slight_smile:

but you should try to format your code with tabs, so that its like this:

function Update()
{
	// tab out to this after every opened bracket
	myBool = true;
	MyMethod();
	if(myBool)
	{
		// two tabs now, since there is a new if open
		DoMyOtherMethod()
	}
}
// When you format your code this way, its 
// much easier to tell when you just are missing 
// a silly bracket somewhere!!! :)

You need a } at the very end to close the update block :slight_smile: