So I have a city map, but I want police sirens to appear at random times. I’m a builder myself and don’t know how to write scripts. I need suggestions or if possible a script. No need to send me Roblox documents explaining this.
I already have an city ambient and police sirens sounds.
If you want the sounds to come from a certain location put the siren Sound in a Part at that location.
If you want it to be heard all over the map put it into the workspace.
You can put a fairly simple script inside the sound
local sound = script.Parent
while true do
task.wait(math.random(120,240)) -- random time in seconds between the min and max values
-- change the min and max to what you need, just make the min longer than the length of the siren audio
sound:(Play)
end
There was a small problem the script did not work.
local sound = script.Parent
while true do
task.wait(math.random(120,240)) -- random time in seconds between the min and max values
-- change the min and max to what you need, just make the min longer than the length of the siren audio
sound:(Play)
end
I fixed from :(Play) to :Play() and now it works. Thanks
This worked. But siren sound still plays at the same timing even if I change the values.
Hehe sorry, my bad with the Play() issue.
Make sure the 2nd number is larger because math.random chooses between the 1st and 2nd.
If the siren Sound is 20 seconds long then make the 1st number greater than 20, and make the 2nd number something like 300 (5 min.) so that players don’t keep hearing it over and over.
Finnaly solved my problem. Thank you.