# \*\*\* need help debugging this code \*\*\*

**URL:** <https://forum.code.org/t/need-help-debugging-this-code/23043>\
**Category:** Uncategorized\
**Created:** [December 4, 2018, 10:49pm UTC](https://forum.code.org/t/need-help-debugging-this-code/23043 "2018-12-04T22:49:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![misterellis](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@misterellis](https://forum.code.org/u/misterellis)\
**Post date:** [December 4, 2018, 10:49pm UTC](https://forum.code.org/t/need-help-debugging-this-code/23043/1 "2018-12-04T22:49:39Z")

</div>

My best student came up with a game where you click on certain sprites and they disappear, adding 1 to the score at the top-left of the game screen. When the score reaches 8, the sprites change to a different animal.

The problem is that when she runs the program, the numbers in the score don’t go up by one each time she clicks on a sprite. It might be a 3, 4, 6, or whatever, even though she’s only clicked on one sprite.

Can you help debug the code–please!? It’s from Unit 3, Lesson 22:11 of Computer Discoveries.

> **[Check out what I made](https://studio.code.org/projects/gamelab/tMpIzl65yleBpHQw6gqi027gmOoWi9j2g6-iLbUH8-A)**
>
> I wrote the code myself with Code.org

Thanks very much!

Gary Ellis  
Middle School Teacher

---

<div class="post-metadata">

**Author:** ![mike](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mike/32/5229_2.png) [@mike](https://forum.code.org/u/mike)\
**Post date:** [December 5, 2018, 4:29pm UTC](https://forum.code.org/t/need-help-debugging-this-code/23043/2 "2018-12-05T16:29:17Z")

</div>

Hi Gary,  
`mousePressedOver()` is true any time the mouse button is being held down. I found I could actually score points my just clicking and dragging around over the various sprites. To make sure you you only get one point per click, she may want to check if the mouse _just_ went down. Something like:  
`if (mouseWentDown("leftButton" && mouseIsOver(sprite))`

---

<div class="post-metadata">

**Author:** ![misterellis](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@misterellis](https://forum.code.org/u/misterellis)\
**Post date:** [December 5, 2018, 11:13pm UTC](https://forum.code.org/t/need-help-debugging-this-code/23043/3 "2018-12-05T23:13:52Z")

</div>

Superb, Mike! It worked. Thanks very much.

Gary
