How to make a audio not reset when you die

Hello I made an Audio GUI for my game Tower of Insanity and I noticed that when I die the audio resets. I was kind of bummed I tried looking for help in discord servers but then I used my BIG BRAIN and thought of asking you guys. If you know how to fix this please tell me ASAP thank you for your time :slight_smile:

Code:
local MarketPlaceService = game:GetService(“MarketplaceService”)
–Song Ids :slight_smile:
local Songs = {
4981969796,
5609469033,
1051512943,
2590490779,
152828706,
1444622447,
5450766448,
4879614820,
3749844870,
5629867848,
949399870
}
–Gui parts vars
local SongPart = script.Parent.Sound
local SongName = script.Parent.SongName
local NextButton = script.Parent.NextButton
local MuteButton = script.Parent.MuteButton
–Loop to play song
MuteButton.MouseButton1Click:Connect(function()
–song part is the sound
if SongPart.Volume == 0.5 then
SongPart.Volume = 0
else
SongPart.Volume = 0.5
end
end)
–Next song button to skip to the next song on the table
NextButton.MouseButton1Click:Connect(function()
SongPart:Stop()
end)

while true do
–getting the songs from the table
for i = 1, #Songs do
local Song = Songs[i]

	local SongInfo = MarketPlaceService:GetProductInfo(Song)
	--displaying the name of the song by concatonating
	SongPart.SoundId = "rbxassetid://" .. Song
	
	SongPart:Play()
	
	SongPart.Visible = true
	
	SongName.Text = SongInfo.Name
	
	wait(3)
	
	SongName.Visible = false
	
	repeat wait() until not SongPart.IsPlaying
	
end

endPreformatted text

image

1 Like
local SongPart = (workspace.CurrentCamera:FindFirstChild("Sound") == nil) and Instance.new("Sound", workspace.CurrentCamera) or workspace.CurrentCamera:FindFirstChild("Sound")
1 Like
1 Like

I suggest turning off the ResetOnSpawn property of the ScreenGui because when the player respawns, the children of the ScreenGui are reset like the way they were the first time.

It worked thanks so much have a nice day :slight_smile:

1 Like

Thank you for the info I will def look at it!

1 Like