Random Variable to use as wait time

Hi all, I'm trying to have a sound effect play at random intervals in the background of one of my maps. I am so lost, I've tried the random control variables and using ruby to script and still can't find out how to use the random variable as a # of frames for wait time. Any help or direction is greatly appreciated
You could create a timer loop in a parallel event either on the map or a common event if you plan to use it often on multiple different maps.
Use a control variable. Let's call this variable "Timer"
Control variable, random 60 ~ 300.
//this is picking a random amount of time which our loop below will begin counting down from.
Create a loop.
Loop:
If "Timer" is < 0
PLAY SFX
break loop
//above is used to determine what happens when the timer has reached the end
Else
"Timer" - 1
Wait 1 frame
//this is used to count down the timer. It's important to have a wait frame to reduce the amount of cycles and processing the game needs to do for the event. In my opinion, this is a non-critical event, so you may want to use a longer wait time. 60 is good, since 60 frames will be 1 second. If you change the wait to 60, be sure to adjust the Timer variables random value range (otherwise if it rolls a 300, that means it will be 300 seconds until it triggers the sound)
End
Loop end

*on my phone, sorry for the lack of screen shots and weird formatting. If no one replies by the time I get home, I'll make a post that more clearly shows what I'm talking about if you don't understand.
Ah, it works! Thanks so much!
@spumoni are you using VX or VX Ace? Your profile says you're using Ace, but you posted in the support forum for VX.
Sorry about that, I am using ace - I'm new to the forums so I got mixed up.
Moved to: VX Ace Support

No worries. Just be careful where to post - we have support forums and script/plugin request forums for each version of the engine, and what works for one may not work for another.

Original thread: https://forums.rpgmakerweb.com/threads/random-variable-to-use-as-wait-time.157814/