--// SERVICES local SoundService = game:GetService("SoundService") --// CHILL MUSIC PLAYLIST (Roblox Sound IDs) local chillPlaylist = { "rbxassetid://1837879082", -- Chill Lofi 1 "rbxassetid://1839841807", -- Chill Lofi 2 "rbxassetid://9043887091", -- Ambient Chill "rbxassetid://9042539129", -- Relaxing Beats "rbxassetid://1845341258", -- Smooth Vibe "rbxassetid://1848354536" -- Soft Aesthetic } -- Create a dedicated Sound instance local musicSound = Instance.new("Sound") musicSound.Name = "BackgroundChillMusic" musicSound.Volume = 0.5 musicSound.Looped = false musicSound.Parent = SoundService local remainingPlaylist = {} -- Function to shuffle table randomly (Fisher-Yates Shuffle) local function shufflePlaylist() remainingPlaylist = {} for _, soundId in ipairs(chillPlaylist) do table.insert(remainingPlaylist, soundId) end for i = #remainingPlaylist, 2, -1 do local j = math.random(i) remainingPlaylist[i], remainingPlaylist[j] = remainingPlaylist[j], remainingPlaylist[i] end print("[Music Player] Playlist shuffled. " .. tostring(#remainingPlaylist) .. " tracks loaded.") end -- Function to play next unique song local function playNextSong() -- Refill and shuffle if playlist is empty or all tracks played if #remainingPlaylist == 0 then shufflePlaylist() end -- Pick the top track and remove it from the pool to prevent repeats local nextTrack = table.remove(remainingPlaylist, 1) musicSound.SoundId = nextTrack musicSound:Play() print("[Music Player] Now playing: " .. nextTrack) end -- Play next track automatically when the current one ends musicSound.Ended:Connect(playNextSong) -- Start the music player playNextSong()