Discuss Scratch

JacktheEngineer
Scratcher
28 posts

why does clicking the green flag twice fix lag

hi guys so i was wondering about the “press green flag twice to reduce lag” thing on scratch.
does it really work and if so how does it work?

thanks
thegoofhere
Scratcher
79 posts

why does clicking the green flag twice fix lag

Magic.
Blocks can sometimes not load properly, so you'd need to click it again
awesome-llama
Scratcher
1000+ posts

why does clicking the green flag twice fix lag

Do you have a project where this is the problem?

“click the green flag twice” is most often indicative of code that has not been given a clear order to run in. A script that resets a variable might run before that variable is used by another script, so clicking the flag again ensures that any use of that variable happens after it was already reset. Usually the scripts can be combined or triggered by broadcasts so that the order is clear and guaranteed.

Example of problematic code (don't do this):

whenclickedwaituntilscore>10 there is no guarantee that the score is resetsayyou win!whenclicked this resetting script might run after the abovesetscoreto0

This can be solved like this:

whenclickedsetscoreto0 score is reset before it is usedwaituntilscore>10sayyou win!

Alternatively with broadcasts:
(in larger projects this is a lot more useful. I prefer this method.)

whenclicked the broadcasts below will always start in the given orderbroadcastresetbroadcaststart score checkwhenIreceiveresetsetscoreto0whenIreceivestart score checkwaituntilscore>10sayyou win!

Last edited by awesome-llama (March 24, 2025 07:20:50)

Powered by DjangoBB