# While Loop

**URL:** <https://forum.makecode.com/t/while-loop/33769>\
**Category:** Help\
**Created:** [February 10, 2025, 6:44pm UTC](https://forum.makecode.com/t/while-loop/33769 "2025-02-10T18:44:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mlabrenz](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@Mlabrenz](https://forum.makecode.com/u/Mlabrenz)\
**Post date:** [February 10, 2025, 6:44pm UTC](https://forum.makecode.com/t/while-loop/33769/1 "2025-02-10T18:44:24Z")

</div>

Hi! One of my students is trying to use a while loop under the “on A button pressed” event handler. When the condition countdown \> 0 is true, he wants the camera to shake. When he adds in the loop and presses the A button, the code stops running. Any ideas on how to get this loop to run properly? Thank you!

> **[Super Bowl Project - Green](https://arcade.makecode.com/S55898-38901-26824-55548)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [February 10, 2025, 6:56pm UTC](https://forum.makecode.com/t/while-loop/33769/2 "2025-02-10T18:56:43Z")

</div>

`while (true)` has no exist condition, so it’ll stay in that forever. If he wants the loop to stop when countdown is no longer \>= 0, he’d want something like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/9/0/905af29666997ba4313a407304c84f76b5dde63b.png)

but in this case there wouldn’t be _that_ much of a difference, because the countdown running out means the game over screen will pop up. Having the loop in the ‘on a pressed’ itself also has some behavior associated with it; on a pressed will only run one at a time, but from the current game it doesn’t seem like an issue (and we could work around if needed).

What would he like to see change in the game behavior wise?
