Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[Solved] How to have the music system not restart when you die?

I have a music system. It plays the music and displays it on a gui. I also have a mute button which mutes the music. Whenever the music starts playing it plays just like normal. It plays and displays on the gui. But whenever I die it restarts from the first song. Does anybody have an Idea on how to make it so it doesn't restart when I die and it just goes normally.

local MarketPlaceService = game:GetService("MarketplaceService")

local Songs = {
	2985440580,
	396040845,
	5015230842
}

local SongObject = script.Parent.Song
local SongLabel = script.Parent.SongLabel
local MuteButton = script.Parent.MuteButton

MuteButton.MouseButton1Click:Connect(function()
	if SongObject.Volume == 0.5 then
		SongObject.Volume = 0
	else
		SongObject.Volume = 0.5
	end
end)

while true do
	for i = 1, #Songs do
		local Song = Songs[i]
		local SongInfo = MarketPlaceService:GetProductInfo(Song)
		SongObject.SoundId = "rbxassetid://"..Song
		SongObject:Play()
		
		SongLabel.Visible = true
		SongLabel.Text = SongInfo.Name
		
		wait(3)
		SongLabel.Visible = false
		
		repeat wait() until SongObject.IsPlaying == false
	end
end

1 answer

There is a property in the ScreenGui object called "ResetOnSpawn", untick this.

This discussion is preserved as it was. New answers, comments, and votes are closed.