So I want a background ambient sound to play at random times, can someone help me for the script, it has to be played at random and the minimum gap is around 30 seconds, and remember I want the same ID to be played.
Help will be very appreciated! :)
math.random() is your friend. It can generate random numbers for you. It's quite easy to use.
math.random(min, max)
So in your case to generate a random number from 30 to, let's say, 60:
math.random(30,60)
You want to use these numbers as delays. For that you need the wait function.
wait(seconds)
Putting it together:
wait(math.random(30,60))
I'm going to assume that you already have a sound instance in a variable called ambient. Here's how to play it.
ambient:Play()
Finally, you should put all this in an (infinite in this example) loop, so it doesn't just play once. Let's use a while loop.
while CONDITION do end
Putting it all together:
while true do wait(math.random(30,60)) ambient:Play() end