# Why doesn't my timer work the way I want it to?

**URL:** <https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309>\
**Category:** Questions about Thunkable X\
**Tags:** beginner\
**Created:** [January 26, 2020, 3:01pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309 "2020-01-26T15:01:09Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.wulfers4ylq9](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@michael.wulfers4ylq9](https://community.thunkable.com/u/michael.wulfers4ylq9)\
**Post date:** [January 26, 2020, 3:01pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/1 "2020-01-26T15:01:09Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/2/3206f087f55f4a0c80c0318fb48dd65708ac4c4e.png) ![question2](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/b/5bba6ed9adc437810bab8503ebd2119d6fd7ebd8.png) ![question3](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/f/6fefdc8cb1ed9d3662a0b080b46224f413de272b.png)

Hi, I’m pretty new to Thunkable and a little bit confused as to why the timer stops working when a sprite of “sprite type 1” is clicked for the first time?  
The way I see it, everytime a sprite of “sprite type 1” is clicked, the timer should start from ten and a certain number of sprites should be relocated (or newly created). But as I can tell from testing the app, all works perfectly fine until a sprite of “sprite type 1” is clicked. Afterwards only the score goes up when ever such a sprite is clicked.  
Furthermore, the app doesn’t always act the same when started. Sometimes no sprites appear at all.  
The only reason I can think of as to why this is, is that they are too many blocks in “game”, but I’m not totally sure, why I hope to get some help from you.

Do you see any mistakes in the script?

There are some more blocks only concerning the sprites’ speed, which I cannot post due to the limitation of pictures.

The game is supposed to be similiar to this one minigame from “Super Mario 64 DS” called “Wanted!”.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 26, 2020, 3:25pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/2 "2020-01-26T15:25:50Z")

</div>

can you try nesting statements? in the ‘then do’ section? i wonder if there is a reason you didn’t do that, perhaps?

 ![Screen Shot 2020-01-26 at 10.13.24 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/0/20370971da66156bca2d22c12f11b9052b0664dc.png)

---

<div class="post-metadata">

**Author:** ![Chris](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/chris/32/78883_2.png) [@Chris](https://community.thunkable.com/u/Chris)\
**Post date:** [January 26, 2020, 3:27pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/3 "2020-01-26T15:27:13Z")

</div>

Hi @michael.wulfers4ylq9,

I am not exactly sure what you want to achieve but to me one issue seems to be that I cannot find any event that starts the timer and also no event when the timer fires in your blocks.

[https://docs.thunkable.com/timer](https://docs.thunkable.com/timer)

Best, Chris

---

<div class="post-metadata">

**Author:** ![michael.wulfers4ylq9](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@michael.wulfers4ylq9](https://community.thunkable.com/u/michael.wulfers4ylq9)\
**Post date:** [January 26, 2020, 3:38pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/4 "2020-01-26T15:38:38Z")

</div>

First of all, thank you for answering so quicky.

In the second picture at the top the timer is set to 10 and in the third picture at the top the timer is started, isn’t it?

---

<div class="post-metadata">

**Author:** ![Chris](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/chris/32/78883_2.png) [@Chris](https://community.thunkable.com/u/Chris)\
**Post date:** [January 26, 2020, 3:42pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/5 "2020-01-26T15:42:22Z")

</div>

Hey,

you set a variable to 10 but I cannot see any block related to the [timer component.](https://docs.thunkable.com/timer). Or am I getting you wrong that you want to start a timer that fires an event after a certain period of time once a sprite is touched?

![assets--LAn5scXl2uqUJUOqkJo--LAn5wecEraNWaG7Ig2g--LAn6DqxCHVuFGG2lVMd-timer-✕-fig-1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/e/be97821adf42ec0adaea7e9659bf5e56e424e6d5.png)

Best, Chris

---

<div class="post-metadata">

**Author:** ![michael.wulfers4ylq9](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@michael.wulfers4ylq9](https://community.thunkable.com/u/michael.wulfers4ylq9)\
**Post date:** [January 26, 2020, 3:43pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/6 "2020-01-26T15:43:00Z")

</div>

You mean filling the gap in the violet block?  
My only intent is to creat a sprite and I don’t really know what the gap is used for. When created the sprites only purpose is to exist.

---

<div class="post-metadata">

**Author:** ![michael.wulfers4ylq9](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@michael.wulfers4ylq9](https://community.thunkable.com/u/michael.wulfers4ylq9)\
**Post date:** [January 26, 2020, 3:44pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/7 "2020-01-26T15:44:27Z")

</div>

The game is supposed end once the timer reaches zero. Did you see the blocks in the second picture at the top? There it should tell the app to count down to zero.

---

<div class="post-metadata">

**Author:** ![Chris](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/chris/32/78883_2.png) [@Chris](https://community.thunkable.com/u/Chris)\
**Post date:** [January 26, 2020, 3:44pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/8 "2020-01-26T15:44:59Z")

</div>

> [@michael.wulfers4ylq9](#):
>
> The game is supposed end once the timer

Then you need to add the timer component.

---

<div class="post-metadata">

**Author:** ![michael.wulfers4ylq9](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@michael.wulfers4ylq9](https://community.thunkable.com/u/michael.wulfers4ylq9)\
**Post date:** [January 26, 2020, 3:50pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/9 "2020-01-26T15:50:14Z")

</div>

Ok, I see what you mean. I’m referring to the variable called timer, which I intended to programm a timer with. Shouldn’t a variable that is changed every second by -1 work as well?

My two main problems are that the timer stops when a sprite of “sprite type 1” is clicked and that the script inside the “when Sprite\_Type1 is clicked” only appears to work the first time.

---

<div class="post-metadata">

**Author:** ![Chris](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/chris/32/78883_2.png) [@Chris](https://community.thunkable.com/u/Chris)\
**Post date:** [January 26, 2020, 4:53pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/10 "2020-01-26T16:53:33Z")

</div>

> [@michael.wulfers4ylq9](#):
>
> Shouldn’t a variable that is changed every second by -1 work as well?

Yes, that would work too but I also cannot find any block that causes a 1 second delay. Therefor my guess is that whenever you press a Sprite your variable might be reduced by -1 but it will not work as expected.

Best, Chris

---

<div class="post-metadata">

**Author:** ![michael.wulfers4ylq9](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@michael.wulfers4ylq9](https://community.thunkable.com/u/michael.wulfers4ylq9)\
**Post date:** [January 27, 2020, 3:48pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/12 "2020-01-27T15:48:40Z")

</div>

I’m talking about these blocks. Shouldn’t they function as a timer? ![question5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/7/d7a3015900b308ee0b36ef244d0b31bef3c94e52.png)

This image is the upper section of the second image I posted in the beginning.

---

<div class="post-metadata">

**Author:** ![Chris](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/chris/32/78883_2.png) [@Chris](https://community.thunkable.com/u/Chris)\
**Post date:** [January 27, 2020, 6:14pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/13 "2020-01-27T18:14:00Z")

</div>

Oh sorry I didn’t see the wait block. Have you tried replacing the “forever” with something like “repeat while”?

---

<div class="post-metadata">

**Author:** ![michael.wulfers4ylq9](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@michael.wulfers4ylq9](https://community.thunkable.com/u/michael.wulfers4ylq9)\
**Post date:** [January 28, 2020, 2:40pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/14 "2020-01-28T14:40:10Z")

</div>

Thank you for answering.

I’m gonna try it.

---

<div class="post-metadata">

**Author:** ![michael.wulfers4ylq9](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@michael.wulfers4ylq9](https://community.thunkable.com/u/michael.wulfers4ylq9)\
**Post date:** [January 28, 2020, 3:00pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/15 "2020-01-28T15:00:38Z")

</div>

This way it should work, shouldn’t it? Would a block, if placed right underneath the “repeat while” block, only be activated, if the loop was over?

 ![Screenshot (63)](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/e/7e8b2815c898d52cb09322f3a7b0b55a092bafed.png)

---

<div class="post-metadata">

**Author:** ![Chris](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/chris/32/78883_2.png) [@Chris](https://community.thunkable.com/u/Chris)\
**Post date:** [January 29, 2020, 9:41pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/16 "2020-01-29T21:41:19Z")

</div>

Yes, actually this should work similar to using a timer component.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 29, 2020, 10:28pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/17 "2020-01-29T22:28:19Z")

</div>

Your code, which I’ve sketched below, should subtract one from the variable value every second until the condition is false. So, no, it shouldn’t only be activated after the loop ended. It should be activated within the loop.

Repeat while [condition]  
\_\_\_\_\_do  
\_\_\_\_\_\_\_\_\_\_wait 1 seconds  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_change variable

---

<div class="post-metadata">

**Author:** ![michael.wulfers4ylq9](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@michael.wulfers4ylq9](https://community.thunkable.com/u/michael.wulfers4ylq9)\
**Post date:** [February 7, 2020, 3:23pm UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/18 "2020-02-07T15:23:49Z")

</div>

I tried it and it appears to be working better, Thank you very much!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:41am UTC](https://community.thunkable.com/t/why-doesnt-my-timer-work-the-way-i-want-it-to/428309/19 "2024-11-08T11:41:09Z")

</div>


