-
What do you want to achieve? Make it so every time the music is ended, it is changed to a random ID and then re-starts playing with the new ID
-
What is the issue? For some reason my script seems to make songs end prematurely and also nothing plays after one change of ID.
-
What solutions have you tried so far? I tried putting the function in a loop like shown in the code but it did not work either.
Script in ServerScriptService
local ids = {"rbxassetid://1846009879","rbxassetid://1839906422","rbxassetid://1836289256","rbxassetid://1847223170"}
local music = game:GetService("Workspace").Music
while true do
wait(4)
music.Ended:Connect(function()
print("song ended")
music.SoundId = ids[math.random(1,#ids)]
print("song changed")
music:Play()
print("new song played")
end)
end