help with UCE0001: ';' expected. Insert a semicolon at the end

i have an error that says
Assets/My Stuff/scripts/dooropen.js(21,64): UCE0001: ‘;’ expected. Insert a semicolon at the end.

if(hit.gameObject.tag == "CrateHealth")

{

	Destroy(hit.gameObject);
	
	health += 50;
	
	GameObject.Find("GUI_Lives").guiTexture.texture "" + health;
}

can someone tell me what is wrong please

.texture “” +

what’s with the quotes?

And why bother to Find if you aren’t going to assign it to something?

And, you can’t add an integer to a texture anyway.

What are you intending to do, maybe we can give you exact syntax.

GameObject.Find(“GUI_Lives”).guiTexture.texture “” + health;

This line doesn’t do anything. Correct your code and it’ll hopefully go away.

The error is saying that the compiler expects a semicolon on line 26 which, I can only assume, is this line. The way you’ve written that line doesn’t make sense; what were you trying to do?

This is the line with the problem:

GameObject.Find("GUI_Lives").guiTexture.texture "" + health;

You are trying to put a string into a Texture field with ""+health,
but the compiler is looking to either return the value of guiTexture.texture,
or assign into the value.

It does not see an assignment so it returns the value of guiTexture.
Then, it sees you trying to concatenate a String and a number.
That has nothing to do with guiTextures, so the compiler looks at it
like a new line. But there is no semicolon separating the lines,
so that is when you get your error.

Fixing:

  • First, try using a GUIText Object instead of a GUITexture like you are
    using. A GUIText allows you to put text on the screen while a GUITexture only
    allows you to put a premade image on the screen.

  • make sure you have an = sign if you are changing a value.
    It will give you a more descriptive error message.