I’m creating a script to function a music playlist. While the playlist itself works fine, the problem is when I die or reset my character, the entire playlist starts all over. What I want to happen is to have it keep playing the music while also not restarting anything related to the playlist. I’ve tried looking for a few solutions but none of them were that helpful.
This script and sound is located in a ScreenGui.
local muteButton = script.Parent.Mute
local skipButton = script.Parent.Skip
local currentSongDisplay = script.Parent.CurrentSongDisplay
local musicPlayer = script.Parent.Music
local marketplaceService = game:GetService("MarketplaceService")
local songs = {
9048538224,
1844487326,
1847644994,
9042620422
}
muteButton.Activated:Connect(function()
if musicPlayer.IsPaused == false then
musicPlayer:Pause()
muteButton.Image = "rbxassetid://10335260788"
muteButton.HoverImage = "rbxassetid://10335260924"
muteButton.PressedImage = "rbxassetid://10335261069"
else
musicPlayer:Resume()
muteButton.Image = "rbxassetid://10335260301"
muteButton.HoverImage = "rbxassetid://10335260432"
muteButton.PressedImage = "rbxassetid://10335260659"
end
end)
skipButton.Activated:Connect(function()
musicPlayer.TimePosition = musicPlayer.TimeLength
end)
while true do
for count = 1, #songs do
musicPlayer.SoundId = "rbxassetid://"..songs[count]
songInfo = marketplaceService:GetProductInfo(songs[count])
if not musicPlayer.IsLoaded then musicPlayer.Loaded:Wait() end
musicPlayer.TimePosition = 0
musicPlayer:Play()
currentSongDisplay.Text = ""..songInfo.Name
musicPlayer.Ended:Wait()
currentSongDisplay.Text = ""..songInfo.Name
end
end