Sound Loop Won't Work

I do not know whether this is a bug or not, so I put it in this category just in case for now. I have made a loop for playing music in my game, but after the first song plays, the second one doesn’t and it totally messes up everything. If there is another way to do this and my loop is the reason why it will not play, please tell me and I will fix it, otherwise I think there might be a bug going on with the sounds.

Script
local s = game:GetService("SoundService")
while true do
	s.Gameplay.Main:Play()
	wait(107)
	s.Gameplay.Main:Stop()
	print("next")
	s.Gameplay.DarkMoon:Play()
	wait(75)
	s.Gameplay.DarkMoon:Stop()
	s.Gameplay.PianoSong:Play()
	wait(82)
	s.Gameplay.PianoSong:Stop()
	s.Gameplay.BossFight:Play()
	wait(118)
	s.Gameplay.BossFight:Stop()
	s.Gameplay.PhantomDancing:Play()
	wait(226)
	s.Gameplay.PhantomDancing:Stop()
end

I have this in a (Server)Script in workspace and I am using sound-regions for the songs, but it shouldn’t effect the playing issue since it focuses on volume. Any Help Is Appreciated! :grin:

2 Likes

Is it a local script placed in the workspace? Because the workspace is not server specific.

I said it was a script in workspace, let me try moving it to ServerScriptService.

Then that’s the problem. Scripts in workspace won’t run of themselves. You could either make it a module and call a function or place the script in PlayerScripts. Or as you said, move it to the server.

1 Like

Thank you! I am testing it now. (glad I put this in the scripting support category lol) It is still not working :frowning: trying PlayerScripts now.

1 Like

No problem, if it works make sure to mark it as the solution so other people can quickly find the answer.

I’d move it to the PlayerScripts since from what i can understand, this music should be played individually and not the same for everyone on the server?

1 Like

I ended up getting it to work by doing what you said, put the scripts in StarterPlayerScripts. Thanks For All Of The Help I Really Appreciate It!

2 Likes