Why not use Math.Random() to choose a random song. or use tables?
Random song from playlist script
local songs = {"SongID","SongID","SongID","Just keep putting "" and a , for more songs"}
local songplaying = false
spawn(function()
while songplaying == false do
wait()
for i,v in pairs(songs) do
local randomsong = songs[math.random(1,#songs)]
wait()
if not game.Workspace:FindFirstChild("GlobalSong") then
local sound = Instance.new("Sound")
sound.Name = "GlobalSong"
sound.Parent = game.Workspace
end
songplaying = true
game.Workspace.GlobalSong.SoundId = randomsong
game.Workspace.GlobalSong:Play()
game.Workspace.GlobalSong.Ended:Wait()
songplaying = false
end
end
end)
Play song in order
local songs = {"SongID","SongID","SongID","Just keep putting "" and a , for more songs"}
local songplaying = false
spawn(function()
while songplaying == false do
wait()
for i = 1,#songs do
wait()
if not game.Workspace:FindFirstChild("GlobalSong") then
local sound = Instance.new("Sound")
sound.Name = "GlobalSong"
sound.Parent = game.Workspace
end
songplaying = true
game.Workspace.GlobalSong.SoundId = songs[i]
game.Workspace.GlobalSong:Play()
game.Workspace.GlobalSong.Ended:Wait()
songplaying = false
end
end
end)
2 comments
check if the last song in the playlist has ended, and then restart it by setting current song back to 1.
Yeah, the last song ended. I restarted the currentSong back to 1, but still doesn't work.