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 skylerkinjorski · Jan 31, 2014 at 12:58 PM · javascripterrorassets

Why am I getting this error repeatedly?

Assets/scripting_basics2.js(106,21): BCE0067: There is already a local variable with the name 'doesFightHappen'. error, I'm just learning to use javascript, and just playing around, and this is the script. . .

 function Update ()
     
 {
 
 var skylerHappy : boolean = true;
 var meganHappy = false;
 var skylerCigarretes = 4;
 var meganShoesOn = true;
 var dishesInSink = true;
 var poopOnFloor = true;
 var doesFightHappen : boolean = false;
 
 
     
     if (skylerHappy == true && skylerCigarretes >= 2)
         {
         var doesFightHappen = false;
         print (doesFightHappen);
         }
     else 
         {
         var doesFightHappen = true;
         print (doesFightHappen);
         }
 }
 
 
 K, so it may be sloppy, and I'm sure I messed it up somewhere stupid, but why wouldn't I be able to change that variable like that to true if I was not happy, and did not have smokes left?!?!?  I stared at it for 10 minutes, can't find the error, and the error doesn't bother me so much as needing to know why its wrong so I don't do it when I'm actually coding something serious.
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

2 Replies

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

Answer by ffxz7ff · Jan 31, 2014 at 01:30 PM

The error means that you're trying to declare a variable twice. In line 11 of what you posted, var doesFightHappen : boolean = false; you declare it once, then later you do var doesFightHappen = false; or var doesFightHappen = true; again.

Just drop the var in your if/else clause. It should simply be doesFightHappen = false; or doesFightHappen = true;.

And by the way this would have been easy to google up.

Comment
Add comment · Show 1 · 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 skylerkinjorski · Jan 31, 2014 at 09:02 PM 0
Share

Ohh. . .your right. I see exactly what your talking about. . .btw, I did google it for quite a while, also, i had been staring at code for like 6 hours straight by that point, so I wasn't all there. Thanks for the answer though! $$anonymous$$uch appreciated!

avatar image
0

Answer by james_170482 · Jan 31, 2014 at 04:16 PM

I don't use JavaScript but i think its because in your if statement you use the var doesFightHappen = false instead of just doesFightHappen = false, creating a new instance of the same boolean, i could be wrong but just try removing the var.

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

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

20 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

Related Questions

simple error messages, need help with them. 0 Answers

enemy mechanics script and declining health 1 Answer

Semi colon placement? unity error message 2 Answers

Major errors on Build/export of game (CODING HELP NEEDED) 1 Answer

Help !! MIssing Semi colon in my coding 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