Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make a sound play at regular intervals?

I've tried a few solutions, such as this one

b=true
while true do
Game.Workspace.WhistleUnion.Toot.playing=true
Game.Workspace.WhistleUnion.Toot.looped=true
wait(5)
Game.Workspace.WhistleUnion.Toot.playing=false
Game.Workspace.WhistleUnion.Toot.looped=false
wait(25)

but I'm stumped. I can't make the sound play at all.

1 comment

0

Is there and "end" to this loop? Also format your code better please.

1 answer

Based on your above code, you need to make sure you are using the correct spellings of Properties, since Lua is Case Sensitive.

This being said, here are the revisions based on this (for a single sound)

while true do
	workspace.WhistleUnion.Toot:Resume()
	workspace.WhistleUnion.Toot.Looped = true
	wait(5)
	workspace.WhistleUnion.Toot:Pause()
	workspace.WhistleUnion.Toot.Looped = false
	wait(25)
end

Using Resume and Paused will make the sound stop when it last was then continue, or you can start from the beginning by doing

while true do
	workspace.WhistleUnion.Toot:Play()
	workspace.WhistleUnion.Toot.Looped = true
	wait(5)
	workspace.WhistleUnion.Toot:Stop()
	workspace.WhistleUnion.Toot.Looped = false
	wait(25)
end

Either way, the sound will play for 5 seconds, then stop and begin playing 25 seconds later

This discussion is preserved as it was. New answers, comments, and votes are closed.