I want to make a playist that plays music on my game. I want to load the next song before it plays so there is no delay (I use music that are more than 2 min long)
The first song plays, but it just does not trigger the ending event...
The thingis that this works in studio, but not ingame, It does not even do the "End" print ingame from the last lines of the script.
I want to know what's breaking my thing and how could I fix it.
This is the script:
local List = {
[1] = "218607791";
[2] = "218608165";
[3] = "218609229";
}
local Music1 = Instance.new("Sound",game.Workspace)
Music1.Name = "Music1"
Music1.Volume = 0.1
local Music2 = Instance.new("Sound",game.Workspace)
Music2.Name = "Music2"
Music2.Volume = 0.1
local Current = Music2 -- I put this there so it changes to the Music1
local num = 1
function change()
print("Changing")
if Current == Music1 then
Current = Music2
Music2:Play()
Music1.SoundId = "rbxassetid://"..List[num]
elseif Current == Music2 then
Current = Music1
Music1:Play()
Music2.SoundId = "rbxassetid://"..List[num]
end
if num == (#List) then num = 1 else num = num + 1 end
end
Music1.SoundId = "rbxassetid://"..List[1]
change()
Music1.Ended:connect(function()
print("Ended")
Music1:Stop()
change()
end)
Music2.Ended:connect(function()
print("Ended")
Music2:Stop()
change()
end)

5 comments
But I do not want to add delay, I want to have a smooth music change since I use music with 2-3 files.
If you don't want a delay, then simply remove the +1 at the end of each wait
Still works only in studio, but not ingame... (it just spams the prints, I tried adding a delay but still does the thing)
That means it isn't loading fast enough... Add maybe a wait(5) or wait(10) before the loop
Still not working, well only works on studio https://scriptinghelpers.org/questions/26563/can-someone-help-me-with-server-client-studio-sound-problem