# How do I get a tile to call the next level in a game?

**URL:** <https://forum.makecode.com/t/how-do-i-get-a-tile-to-call-the-next-level-in-a-game/14420>\
**Category:** Help\
**Created:** [July 12, 2022, 10:17pm UTC](https://forum.makecode.com/t/how-do-i-get-a-tile-to-call-the-next-level-in-a-game/14420 "2022-07-12T22:17:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoMustangs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gomustangs/32/4323_2.png) [@GoMustangs](https://forum.makecode.com/u/GoMustangs)\
**Post date:** [July 12, 2022, 10:17pm UTC](https://forum.makecode.com/t/how-do-i-get-a-tile-to-call-the-next-level-in-a-game/14420/1 "2022-07-12T22:17:10Z")

</div>

I want to use a tile and function to call the next level in a game every time the player overlaps that tile. Unfortunately, when my player overlaps the tile on first level the game automatically just moves the player to the final level. How do I get this to happen one level at a time?

Here’s the specific code I’m talking about:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/987e53edbe7a44b9c9bc0b3ee69e22844f24d3b2.png)

Here’s the complete game if you want to see how it works:

> **[newGame](https://arcade.makecode.com/58698-92557-11826-02255)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Any help is much appreciated.

---

<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:** [July 12, 2022, 10:19pm UTC](https://forum.makecode.com/t/how-do-i-get-a-tile-to-call-the-next-level-in-a-game/14420/2 "2022-07-12T22:19:59Z")

</div>

Your issue is with the if statements in nextLevel:

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/fd78a6763a32f8a4dbd3621f275fc2d7b62ffc87.png)

The `level2` function sets the level variable equal to 2. When that function call completes and moves on to the next `if` statement its condition also evaluates to true causing `level3` to be called! This is a great example for the debugger; if you set a breakpoint at the top of the `nextLevel` function and step through the code i think you’ll see exactly what’s going on.

To fix it, simply make the second `if` an `else if` instead of its own `if` statement.

---

<div class="post-metadata">

**Author:** ![GoMustangs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gomustangs/32/4323_2.png) [@GoMustangs](https://forum.makecode.com/u/GoMustangs)\
**Post date:** [July 13, 2022, 5:36am UTC](https://forum.makecode.com/t/how-do-i-get-a-tile-to-call-the-next-level-in-a-game/14420/3 "2022-07-13T05:36:02Z")

</div>

Thanks! I switched it to an else if and it works now. I never used the debugger, but I’ll give it a go next time I run into something.
