# 3.22 Score not displaying regardless of sprite order

**URL:** <https://forum.code.org/t/3-22-score-not-displaying-regardless-of-sprite-order/16249>\
**Category:** Unit and Lesson Discussion\
**Tags:** csd-unit-3, csd-unit-3-lesson-22\
**Created:** [May 16, 2018, 9:29am UTC](https://forum.code.org/t/3-22-score-not-displaying-regardless-of-sprite-order/16249 "2018-05-16T09:29:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![caroline.westervelt](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@caroline.westervelt](https://forum.code.org/u/caroline.westervelt)\
**Post date:** [May 16, 2018, 9:29am UTC](https://forum.code.org/t/3-22-score-not-displaying-regardless-of-sprite-order/16249/1 "2018-05-16T09:29:26Z")

</div>

My students are on the final project and are creating games that require a score variable. The ones that are having difficulty have set backgrounds as sprites. No matter how the sprites are ordered, the score stays behind the background sprite.

My thought is that they will need to draw their own background in order for the score to appear, as opposed to having the background set as a sprite. Is this correct?

---

<div class="post-metadata">

**Author:** ![raezer\_gl](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/raezer_gl/32/3212_2.png) [@raezer\_gl](https://forum.code.org/u/raezer_gl)\
**Post date:** [May 16, 2018, 1:26pm UTC](https://forum.code.org/t/3-22-score-not-displaying-regardless-of-sprite-order/16249/2 "2018-05-16T13:26:45Z")

</div>

Put the score text right below the drawSprites in the main function if they are using backgrounds from the library.

drawSprites();  
fill(“yellow”);  
textSize(20);  
text(“Score:”, 5, 5, 20, 20);  
text(score , 70, 5, 20, 20);

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

---

<div class="post-metadata">

**Author:** ![eglaser](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@eglaser](https://forum.code.org/u/eglaser)\
**Post date:** [June 4, 2018, 2:32pm UTC](https://forum.code.org/t/3-22-score-not-displaying-regardless-of-sprite-order/16249/3 "2018-06-04T14:32:37Z")

</div>

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

In the above game, no matter the order of the code, her score will NOT increase when the apple touches the basket. Any ideas??

---

<div class="post-metadata">

**Author:** ![caroline.westervelt](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@caroline.westervelt](https://forum.code.org/u/caroline.westervelt)\
**Post date:** [June 4, 2018, 2:47pm UTC](https://forum.code.org/t/3-22-score-not-displaying-regardless-of-sprite-order/16249/4 "2018-06-04T14:47:11Z")

</div>

Hi there-

The thing that I see is that there are two if statements regarding whether the apple is touching the basket - one if statement resets the x and y, and the second increases the score. Try dragging the score=score+1 into the first if statement.

So, the code will read:

If apple1 is touching basket:

---

<div class="post-metadata">

**Author:** ![caroline.westervelt](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@caroline.westervelt](https://forum.code.org/u/caroline.westervelt)\
**Post date:** [June 4, 2018, 2:50pm UTC](https://forum.code.org/t/3-22-score-not-displaying-regardless-of-sprite-order/16249/5 "2018-06-04T14:50:19Z")

</div>

Hi there-

I see two things:

1. The syntax isn’t correct - it should say scoreIncrease or scoreDecrease - the second word should be capitalized. Also, there are two if statements regarding whether the apple is touching the basket - one if statement resets the x and y, and the second increases the score. Try dragging the score=score+1 into the first if statement.

So, the combined code will read:

If apple1 is touching basket:  
apple1.x=0  
apple1.y=random  
score=score+1

You should be able to eliminate the whole increaseScore function. Hope this helps!

---

<div class="post-metadata">

**Author:** ![clarkea](https://avatars.discourse-cdn.com/v4/letter/c/ba9def/32.png) [@clarkea](https://forum.code.org/u/clarkea)\
**Post date:** [December 18, 2018, 8:58pm UTC](https://forum.code.org/t/3-22-score-not-displaying-regardless-of-sprite-order/16249/6 "2018-12-18T20:58:48Z")

</div>

My student is having trouble getting his score to appear. Any ideas?

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

---

<div class="post-metadata">

**Author:** ![edavis](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/edavis/32/4927_2.png) [@edavis](https://forum.code.org/u/edavis)\
**Post date:** [December 20, 2018, 12:39am UTC](https://forum.code.org/t/3-22-score-not-displaying-regardless-of-sprite-order/16249/7 "2018-12-20T00:39:49Z")

</div>

Looks like they worked it out! 🙂
