Thunder comes before the lightning?

Hi it's me again and my game is still fighting me, now it's managed to get the thunder before the lightning in my storm and i don't know how to fix it. I have the code right here
Spoiler: Code for The lightning for my storm
1627608467309.png
If anyone could help that would be really nice

EDIT: LEGIT STARTED TO WORK AFTER I POSTED THIS *Sigh*
Glad you got it to work! Random question, is there a reason you have it set to last a maximum of 87 minutes?
what do you mean?
Inside the loop you have it flash the screen, wait 30 frames, play the thunder sound, then wait 320 frames. That alone seems like a fine way to have lightning happening every so often, but it will only happen between 450 and 900 times. If I'm remembering frames right, then 350 frames time 900 comes out to roughly 87 minutes. Then the looping stops and no more thunder.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/thunder-comes-before-the-lightning.139073/