Sound stops playing on death

What do you want to achieve? Keep it simple and clear!
Touched part to at least plays the sound again on a player death

What is the issue?
when I die the audio in full game goes into mute mode, or gets disabled…

the script I use that handles touched parts to play audio on a touched part

local LocalPlayer = game:GetService('Players').LocalPlayer
local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:wait()
local HumanoidRootPart = character:WaitForChild('HumanoidRootPart')
local PlayerGui = LocalPlayer.PlayerGui
local currentPlayingSong = nil
LocalPlayer.Character.HumanoidRootPart.Touched:Connect(function(hit)
	if hit.Name == ("SoundPart") then
		local foundSong = PlayerGui.Audio[hit.Sound.Value]
		if currentPlayingSong ~= nil and foundSong ~= currentPlayingSong then
			currentPlayingSong:Stop()
		end
		if foundSong ~= nil and foundSong ~= currentPlayingSong then
			currentPlayingSong = foundSong
			currentPlayingSong:Play()
		end
	end

Does is stop when you die or when you respawn?

Hello, when the player dies their Backpack and PlayerGui is deleted which would cause the song to be deleted too.

Try inserting the sound directly in the Player and that would make it work if you die.

2 Likes

directly into the player where else would it be good to hold the audio?

and wouldn’t the backpack and playergui respawn inside the player after a certain time

Yes, the backpack and playergui would reset when the player dies, but that would also reset any songs in there.

I’m pretty sure if you insert it in a GUI with ResetOnSpawn disabled it would also keep working when you die, PlayerScripts and SoundService would also work I think.

1 Like