--[[
-- DonaldDuck5150 --
]]
local List = {"7023741506", "7023680426", "7029005367", "7028932563", "5409360995", "7023690024", "7029017448", "7029024726"}
local Sound = game.StarterGui.Sounds.BackgroundMusic
while true do
for i = 1, #List do
Sound.SoundId = "rbxassetid://"..List[i]
task.wait(5)
Sound:Play()
task.wait(Sound.TimeLength)
end
end
This is my sound system that I use. It works fine but the song will keep randomly restarting for no reason and I don’t know why. It won’t even be 10 to 20 seconds into the first song and it just randomly starts over.
This is a LocalScript in StarterGui and my sound that I’m using is also in the StarterGui inside of a folder containing my other various sounds.
Any idea why it’s doing this? Is there a better way to write this script or is there a better place to put it?
So, its a simple fix. Put the audio inside SoundService and play the audio through a server script in ServerScriptService
local audio = game:GetService("SoundService"):WaitForChild("audio.Name") -- :WaitForChild so it can load in and find the audio!
if audio then --Checks if the server found the audio or not!
audio:Play() -- Plays the audio
end
I’ve found the solution. All you need to do is put it in StarterPlayerScripts rather than StarterGui because the StarterGui resets every time the player resets. Thank you everyone for pitching in!