Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Dok101 · Sep 04, 2014 at 08:54 PM · javascripterror

9 errors in Javascript

Hello I have a script that deals with buying a car. Here it is #pragma strict

 var NotEnoughMoney : GUIText;
 var YouBoughtTheCar : GUIText;
 
 function Start () {
     Career_Variables = GameObject.Find("career_Variables").GetComponent<Career_Variables>();
     Car_Variables = GameObject.Find("SpawningCarsPlane").GetComponent<ChooseCar1>();
 }
 
 function Update () {
 
             if (Input.GetKeyDown(KeyCode.B))
             {
                 if (Career_Variables.money >= Career_Variables.Price && carSelected == 0 && Car0Bought == false)
                     {    
                         Career_Variables.money = Career_Variables.money - 7500;
                         Car_Variables.Car0Bought = true;
                     }
                         else if (Career_Variables.money <= 7500 && carSelected == 0)
                         {
                         Car_Variables.Car0Bought - false;
                         }
             }
         
                     }
 
 
 
         function BuyCar ()
         {
             if (Career_Variables.money >= Car_Variables.Price && Car_Variables.CarSelected == 0 && !)
             {
             if (Car_Variables.CarSelected == 0)
             {
                 Career_Variables.money = Career_Variables.money - Career_Variables.Price;
                 PlayerPrefs.SetInt("Player Score", 10);
             }
             }
         }

I get 9 errors such as BCE0043: Unexpected token: ). BCE0044: expecting ), found ';'. UCE0001: ';' expected. Insert a semicolon at the end. etc.

Ive been stuck on this for some time. Any help would be fantastic. Thanks in advance

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by AyAMrau · Sep 04, 2014 at 09:03 PM

You have some typos, errors should have line numbers, so just inspect the given line and line before for those.

On line 30 (here) you have a statement:

 if (Career_Variables.money >= Car_Variables.Price && Car_Variables.CarSelected == 0 **&& !**)

There is either something missing or you have extra && ! there

On line 20:

 Car_Variables.Car0Bought **-** false;

Shoul be =

Comment
Add comment · Show 8 · 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 Dok101 · Sep 06, 2014 at 03:18 PM 0
Share

Thanks for your reply. I fixed those 2 errors and that took out 3 of the 9 errors. However I still have 6 errors which I have found out are relating to lines 5&6. I used that exact same format for certain lines in other scripts and it worked perfectly with no errors. Thank you

avatar image AyAMrau · Sep 06, 2014 at 03:46 PM 0
Share

@Dok101 I dont use Unityscript but I think that:

 .GetComponent<Career_Variables>();

is a C# only syntax for get component. You should be using:

 .GetComponent(Career_Variables);
avatar image Dok101 · Sep 06, 2014 at 04:02 PM 0
Share

Thanks for your reply @AyA$$anonymous$$rau . I tried that and I get 12 errors. Basically the errors are telling me that the lines 4&5 have become inactive and are not doing anything in the script.

Thank you

avatar image tanoshimi · Sep 06, 2014 at 04:11 PM 0
Share

Hint: when asking for help, please post your full, exact code and the full, exact error messages it generates...

avatar image Dok101 · Sep 10, 2014 at 07:34 PM 0
Share

Thanks for your advice @tanoshimi .

I get the errors (7,9): BCE0049: Expression 'Career_Variables' cannot be assigned to.

(8,9): BCE0005: $$anonymous$$ identifier: 'Car_Variables'.

(15,80): BCE0019: 'Price' is not a member of 'Career_Variables'.

(15,89): BCE0005: $$anonymous$$ identifier: 'carSelected'.

(15,109): BCE0005: $$anonymous$$ identifier: 'Car0Bought'.

(18,49): BCE0005: $$anonymous$$ identifier: 'Car_Variables'.

(20,92): BCE0005: $$anonymous$$ identifier: 'carSelected'.

(22,49): BCE0005: $$anonymous$$ identifier: 'Car_Variables'.

(33,55): BCE0005: $$anonymous$$ identifier: 'Car_Variables'.

(33,78): BCE0005: $$anonymous$$ identifier: 'Car_Variables'.

(35,29): BCE0005: $$anonymous$$ identifier: 'Car_Variables'.

(37,100): BCE0019: 'Price' is not a member of 'Career_Variables'.

These are the errors I get when change the code from .GetComponent(); to`.GetComponent(Career_Variables);`

Thank you

Show more comments

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

23 People are following this question.

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

Related Questions

Script Errors Not Sure Why 0 Answers

Animation Script Error 1 Answer

Scripting error #2! 2 Answers

problem at adding script 1 Answer

Need Help Understanding Script! (Javascript) 1 Answer


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