# Problem when creating a ranking for a treasure hunt

**URL:** <https://forum.makecode.com/t/problem-when-creating-a-ranking-for-a-treasure-hunt/10174>\
**Category:** micro:bit\
**Created:** [September 23, 2021, 10:12pm UTC](https://forum.makecode.com/t/problem-when-creating-a-ranking-for-a-treasure-hunt/10174 "2021-09-23T22:12:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elenavercher](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@elenavercher](https://forum.makecode.com/u/elenavercher)\
**Post date:** [September 23, 2021, 10:12pm UTC](https://forum.makecode.com/t/problem-when-creating-a-ranking-for-a-treasure-hunt/10174/1 "2021-09-23T22:12:42Z")

</div>

Good morning!

I’m Elena, a teacher from Spain and I’m trying to create a game where the students would look for a microbit (TREASURE) with the help of different micro:bits connected by radio (FINDER). I want to create a ranking so that the students will know the order of the groups that have found the “Treasure” micro:bit. I have created the following code:

TREASURE: [https://makecode.microbit.org/\_JgVV1ahr73wb](https://makecode.microbit.org/_JgVV1ahr73wb)  
FINDER: [https://makecode.microbit.org/\_cki3Mk4XDK8m](https://makecode.microbit.org/_cki3Mk4XDK8m)

They both send the signals and when “Finder” is near “Treasure”, this one should prompt “Winner 1”.

The problem comes when it doesn’t wait until the micro:bit Finder is near, and it prompts “Winner 1” and also, it doesn’t stop counting: winner 1, 2, 3… without another micro:bit around.

What I would like for it would be to wait for the following micro:bit to arrive next to it, so that it would be winner 2. How could I make it?  
Thanks a million!  
Elena

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [September 24, 2021, 3:58pm UTC](https://forum.makecode.com/t/problem-when-creating-a-ranking-for-a-treasure-hunt/10174/2 "2021-09-24T15:58:41Z")

</div>

Here’s how I would do this:

> **[finder (richard's version)](https://makecode.microbit.org/49746-24915-82337-51174)**
>
> Made with ❤️ in Microsoft MakeCode for micro:bit.

> **[treasure (richard's version)](https://makecode.microbit.org/62949-08765-67924-32123)**
>
> Made with ❤️ in Microsoft MakeCode for micro:bit.

I added comments to the code to explain what I’m doing. Let me know if you have any questions!

---

<div class="post-metadata">

**Author:** ![elenavercher](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@elenavercher](https://forum.makecode.com/u/elenavercher)\
**Post date:** [September 27, 2021, 3:29pm UTC](https://forum.makecode.com/t/problem-when-creating-a-ranking-for-a-treasure-hunt/10174/3 "2021-09-27T15:29:38Z")

</div>

THANKS a million, Richard!!! 🥰
