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

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!”.

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

1 Like

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

Best, Chris

1 Like

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?

Hey,

you set a variable to 10 but I cannot see any block related to the timer component.. 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

Best, Chris

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.

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.

Then you need to add the timer component.

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.

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

I’m talking about these blocks. Shouldn’t they function as a timer?question5

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

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

Thank you for answering.

I’m gonna try it.

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?

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

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

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