The order the hat blocks were placed into the project matters. The block with the wait must be placed first.
This project takes advantage of how scratch chooses to defer code when running multiple scripts asynchronously. In non turbo mode, the project performs wait check -> start waiting loop iteration 1 -> deferred because loop end wait check -> done, set turbo mode true. loop -> done, set turbo mode false. Then in turbo mode, it does wait check -> start waiting loop iteration -> loop iteration done -> set turbo mode false wait done -> set turbo mode true