So, here's my problem: I want to make a club in one of my games that plays music in ONLY the club (Area specific music) but, while the script DOES work in playing the music and keeping it in one area, for some reason it plays multiple songs at once. Help?
Here's the script:
sounds = {144498225, 144586529, 142401311, 145068500} for _, audio in pairs(sounds) do game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. audio) end for _, audio in pairs(sounds) do for i = 1, #sounds do local music = Instance.new("Sound", workspace.clubMusic) music.Name = sounds[i] music.SoundId = "http://www.roblox.com/asset/?id=" .. sounds[i] music:Play() print("Waiting: ".. music.TimeLength) wait(music.TimeLength) music:Destroy() end end
Try to add debounce in the "for" loop.
SoundAssets = {144498225, 144586529, 142401311, 145068500} ContentProvider = game:GetService("ContentProvider") IsPlaying = false while ContentProvider.RequestQueueSize < 0 do for _, audio in pairs(SoundAssets) do ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. audio) wait() end end while true do for _, audio in pairs(SoundAssets) do if not IsPlaying then IsPlaying = true local Sound = Instance.new("Sound", workspace.clubMusic) Sound.SoundId = "http://www.roblox.com/asset/?id=" .. audio print("Waiting: " .. Sound.TimeLength) Sound:Play() wait(Sound.TimeLength) Sound:Destroy() IsPlaying = false end end end