Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChristopher Houston
4,030 PointsMy score is double than what it should be.
My score is doubled. If I collect let's say 18 flies it would show up as 36 and if I collect 9 flies the score would say 18.
1 Answer
Justin Horner
Treehouse Guest TeacherHello Christopher,
It sounds like you might have two instances of the same script added to your GameObject instead of just one. This means two instances of your script are executing at runtime and if they're both communicating with a static variable to keep score, they would both add 1 to your score when you collect a fly.
Of course, this is just a guess. If that doesn't seem to be the case, please share the project and I'd be happy to debug the issue with you.
I hope this helps.
Happy Coding :)
Christopher Houston
4,030 PointsChristopher Houston
4,030 PointsThat is, in fact, the problem but I don't know how to fix it.