Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by killerstud3 · Jul 28, 2011 at 04:37 PM · errorsyntax-erroruce0001

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

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Chris D · Jul 28, 2011 at 04:42 PM 1
Share

In the future, please try to put a better title on your questions. In this case, for example, even putting UCE0001: ';' expected. Insert a semicolon at the end. would have been better; "help with scripting" doesn't describe anything about your issue.

avatar image Graham-Dunnett ♦♦ · Jul 28, 2011 at 06:25 PM 3
Share

Pro tip (for the third time today): The error tells you on which line the compiler found a problem. In your case it is on line 21 (and column 64). Double-clicking on the error in Unity will bring up a text editor with the cursor on the problem line. When you post questions to this site it helps enormously if you can add a comment to the code with some indication on which line the error was on. In your code example there is no line 21, so myself and others on this site have to guess where your problem lies. It's crazy to not give us the extra information and only makes people less likely to help you.

avatar image almo · Jul 28, 2011 at 06:37 PM 1
Share

$$anonymous$$aybe adding (Line 21, col 64) to the compiler error would help people realize this. Just a thought. :)

avatar image SisterKy · Jul 29, 2011 at 01:35 AM 0
Share

Uhm... assumption: You have a GUI-Text (or something) that displays your current health-amount. you want to add "50" to the displayed number?

Ins$$anonymous$$d of texture, you need to access the displayed text (most likely a String-variable?).
But adding a number to a String doesn't work that easy either.

Hmm... trying to help you like this won't work out. You have to explain more...

Greetz, $$anonymous$$y.

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by DaveA · Jul 28, 2011 at 04:42 PM

.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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Chris D · Jul 28, 2011 at 04:45 PM

  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?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by SilverTabby · Jul 28, 2011 at 04:46 PM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image killerstud3 · Jul 28, 2011 at 05:03 PM 0
Share

thanks you guys i removed the quotes but now it says

Assets/$$anonymous$$y Stuff/scripts/dooropen.js(21,66): BCE0034: Expressions in statements must only be executed for their side-effects.

avatar image Graham-Dunnett ♦♦ · Jul 28, 2011 at 06:31 PM 0
Share

Yeah, but now your problem is that the line of code does not make sense. As ChrisD said, your code doesn't do anything. You find a game object, access it's guiTexture, then the texture on the guiTexture. You add health. You don't store the result in any variable. And as DaveA said, what does it mean to add an integer to a texture?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Desintergrate Enemies on Dying 4 Answers

Collision Detector script 1 Answer

script help 2 Answers

whats wrong wrong with my script 4 Answers

at booster to an object 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges