Plays a playlist of songs in order using SoundService. Loops automatically.
-- Music Player local SoundService = game:GetService("SoundService") local PLAYLIST = { "rbxassetid://0000000001", "rbxassetid://0000000002", } local SHUFFLE = false local currentIndex = 1 local bgm = Instance.new("Sound") bgm.Volume = 0.5; bgm.Parent = SoundService local function getNext() if SHUFFLE then return math.random(1, #PLAYLIST) end local n = currentIndex + 1; return n > #PLAYLIST and 1 or n end bgm.Ended:Connect(function() currentIndex = getNext(); bgm.SoundId = PLAYLIST[currentIndex]; bgm:Play() end) if #PLAYLIST > 0 then bgm.SoundId = PLAYLIST[1]; bgm:Play() end