A (possibly outdated?) GUI I have used to play music from a playlist. Recently the script hasn't been functioning(as in music does not play) and I'm not quite sure why. Script for the GUI:
local CurrentSong = script:WaitForChild("CurrentSong") local Playlist = script:WaitForChild("Playlist") local gui = script.Parent local MainFrame = script.Parent.SwitchTeam.MainFrame1 local MuteButton = MainFrame:WaitForChild("Mute") local Songs = {} for _, child in pairs(Playlist:GetChildren()) do table.insert(Songs, child.Value) end local songNumber = math.random(1, #Songs) local nextSong = function() if CurrentSong.IsPlaying then CurrentSong:Stop() end songNumber = songNumber + 1 if songNumber > #Songs then songNumber = 1 end CurrentSong.SoundId = Songs[songNumber] CurrentSong.TimePosition = 0 CurrentSong:Play() end CurrentSong.Ended:Connect(nextSong) -- Start music nextSong() MuteButton.MouseButton1Down:Connect(function() if CurrentSong.Volume ~= 0 then CurrentSong.Volume = 0 MuteButton.Text = "Unmute Music" else MuteButton.Text = "Mute Music" CurrentSong.Volume = 0.5 end end)
The mute button does change texts when clicked (obviously I cannot verify if it works anymore because music does not play), however the script WAS functional.
EDIT:
Try using NumberValue
s instead. Inside each NumberValue
are the song ids.
And try waiting for the sound to load first before playing it.
local CurrentSong = script:WaitForChild("CurrentSong") local Playlist = script:WaitForChild("Playlist") local gui = script.Parent local MainFrame = script.Parent:WaitForChild("SwitchTeam").MainFrame1 local MuteButton = MainFrame:WaitForChild("Mute") local SongIds = {} for _, child in ipairs(Playlist:GetChildren()) do if child:IsA("NumberValue") then table.insert(Songs, child.Value) end end local function loadSound(sound: Sound) if not sound.IsLoaded then sound.Loaded:Wait() end end local songNumber = math.random(1, #SongIds) local function nextSong() if CurrentSong.IsPlaying then CurrentSong:Stop() end songNumber += 1 if songNumber > #SongIds then songNumber = 1 end CurrentSong.TimePosition = 0 CurrentSong.SoundId = "rbxassetid://" .. SongIds[songNumber] loadSound(CurrentSound) CurrentSong:Play() end CurrentSong.Ended:Connect(nextSong) -- Start music nextSong() MuteButton.MouseButton1Down:Connect(function() if CurrentSong.Volume ~= 0 then CurrentSong.Volume = 0 MuteButton.Text = "Unmute Music" else MuteButton.Text = "Mute Music" CurrentSong.Volume = 0.5 end end)
--
It's probably because of Roblox removing every audio in the Marketplace back in March 2022. This made uploading audios free but the person who uploaded the audio can only be used in their game. You can also give permission to a game to use your audio but it will also need the developer's permission.
What you can do is replace the audios you're using with the public audios (mostly uploaded by Roblox and some music companies) in the Marketplace such as Life in an Elevator (rbxassetid://1841647093) and the classic Raining Tacos (rbxassetid://142376088).