I am trying to make it so when a player dies the music continues to play, right now, when a player dies the music stops. The system I have set up is I have one event that fires whenever someone touches a part, and then is checking if certain values are set to true, and if they are, it plays a sound that is in StarterGui. Is there a way that it can pause the sound on death and not stop it? Because I want the TimePosition to stay the same. Is there other ways I can go about this? If you could point me in the right direction it would be very appreciated. I looked on the dev hub and the dev forums and could not find an answer.
When a players character dies, their Backpack & PlayerGui is deleted along with them, because those items are given when a character is added. Therefore, the sound will be deleted & stopped too when the character dies.
To have the sound keep playing after death, you can put the sound inside the actual player (game.Players.Playername). If you want to pause it when they die and resume when they respawn, its as simple as hooking up a listener for the characters death, pausing, and then resuming when the character is re-added.
you can see when a player respawns using this code:
game.PlayerAdded:Connect(function(plr)
local Respawns = -1
plr.CharacterAdded:Connect(function(char)
Respawns = Respawns + 1
if Respawns == 1 then
-- Code
end
end)