# Countdown timer question

**URL:** <https://forum.makecode.com/t/countdown-timer-question/1120>\
**Category:** Arcade\
**Created:** [January 27, 2020, 1:52am UTC](https://forum.makecode.com/t/countdown-timer-question/1120 "2020-01-27T01:52:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![markgimein](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/markgimein/32/583_2.png) [@markgimein](https://forum.makecode.com/u/markgimein)\
**Post date:** [January 27, 2020, 1:52am UTC](https://forum.makecode.com/t/countdown-timer-question/1120/1 "2020-01-27T01:52:22Z")

</div>

Has anyone else tried to make a countdown timer that resets at the end of the countdown? My son is working on a game in which each level last 20 seconds. If you survive 20 seconds, you go on to the next level, and the countdown is reset. But the “start countdown” doesn’t seem to get executed if it’s contained _inside_ an “on countdown end”. Any thoughts about what can be done?

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [January 27, 2020, 3:16pm UTC](https://forum.makecode.com/t/countdown-timer-question/1120/2 "2020-01-27T15:16:26Z")

</div>

Does the player lose a life if they run out of time? It might be easier if you post the code you have already either as screenshot or published link from `Share`.

---

<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:** [January 27, 2020, 11:57pm UTC](https://forum.makecode.com/t/countdown-timer-question/1120/3 "2020-01-27T23:57:35Z")

</div>

Oh that’s an annoying bug, will fix. For now, here’s a quick workaround (if he’s okay with using a gray block for now): [https://makecode.com/\_fmH8oFD2u1DP](https://makecode.com/_fmH8oFD2u1DP)

```auto
info.onCountdownEnd(function () {
    control.runInParallel(function () {
        info.startCountdown(20)
    })
})
info.startCountdown(3)

```

The difference there is that in the `on countdown end` I’m calling a function that will ‘delay’ the resetting of the countdown until after the current stuff is done - in this case, that’s until after the game resets the countdown timer on its own. Just copying and pasting the three lines inside of the `on countdown end` and changing the time in the countdown to however many seconds they want should be good for now

Here’s the fix in case your curious: [https://github.com/microsoft/pxt-common-packages/pull/1066](https://github.com/microsoft/pxt-common-packages/pull/1066)

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [January 28, 2020, 1:18am UTC](https://forum.makecode.com/t/countdown-timer-question/1120/4 "2020-01-28T01:18:35Z")

</div>

On the subject of countdown timers, has there been any discussion on choosing the number of decimal places for the value shown in HUD?
