How I can make the sound keep playing after the player dies?

The audio get cloned into the character (inside the radio) when the players dies the song get removed bc when one character dies one new get cloned and the old get removed and I dont know how I can do this like pause the music when the player dies.

the scripts:

This is the remote functions (clones the radio into the player and see if the got the gamepass etc…)
ServerScriptService


local MS = game:GetService("MarketplaceService")

local id = 21914253

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if MS:UserOwnsGamePassAsync(player.UserId,id) then
			local clone = game.ServerStorage.Radio:Clone()
			clone.Parent = character
		end
	end)
end)

game.ReplicatedStorage.RadioEvent.OnServerEvent:Connect(function(player,...)
	local tuple = {...}
	local arg1 = tuple[1]
	local arg2 = tuple[2]

	if arg1 == "PlaySong" then
		local character = player.Character
		local radio = character:FindFirstChild("Radio")
		if radio then
			radio:FindFirstChild("Handle").Sound.SoundId = "rbxassetid://" .. arg2
			radio:FindFirstChild("Handle").Sound:Play()
		end
	elseif arg1 == "StopSong" then
		local character = player.Character
		local radio = character:FindFirstChild("Radio")
		if radio then
			radio:FindFirstChild("Handle").Sound:Stop()
		end
	elseif arg1 == "GiveRadio" then
		local clone = game.ServerStorage.Radio:Clone()
		local character = player.Character
		clone.Parent = character
	end
end)

This is a radio GUI the player plays and stop the music here etc…

local player = game.Players.LocalPlayer
local MS = game:GetService("MarketplaceService")
local RS = game.ReplicatedStorage

local bin = script.Parent

local clicked = false
local RadioframeOn = false
local isRadioGamepass = false

local id = 21914253
if MS:UserOwnsGamePassAsync(player.UserId,id) then
	isRadioGamepass = true
end

MS.PromptGamePassPurchaseFinished:Connect(function(plr,gamePassId,wasPurchased)
	if plr.Name == player.Name and gamePassId == id and wasPurchased then
		isRadioGamepass = true
		bin.RadioFrame.Visible = true
		RS.RadioEvent:FireServer("GiveRadio")
	end
end)

bin.RadioButton.MouseButton1Click:Connect(function()
	if isRadioGamepass then
		if RadioframeOn == false then
			RadioframeOn = true
			bin.RadioFrame.Visible = true
		else
			RadioframeOn = false
			bin.RadioFrame.Visible = false
		end
	else
		MS:PromptGamePassPurchase(player,id)
	end
end)

bin.RadioFrame.Play.MouseButton1Click:Connect(function()
	if not clicked then
		if isRadioGamepass then
			if tonumber(bin.RadioFrame.Input.Text) then
				if MS:GetProductInfo(bin.RadioFrame.Input.Text).AssetTypeId == 3 then
					bin.RadioFrame.Title.Text = MS:GetProductInfo(bin.RadioFrame.Input.Text).Name
					RS.RadioEvent:FireServer("PlaySong",bin.RadioFrame.Input.Text)
				else
					clicked = true
					bin.RadioFrame.Input.Text = ""
					bin.RadioFrame.Input.PlaceholderText = "Song ID"
					wait(3)
					clicked = false
					bin.RadioFrame.Input.PlaceholderText = "Song ID"
				end
			else
				clicked = true
				bin.RadioFrame.Input.Text = ""
				bin.RadioFrame.Input.PlaceholderText = "Song ID"
				wait(3)
				clicked = false
				bin.RadioFrame.Input.PlaceholderText = "Song ID"
			end
		end
	end
end)

bin.RadioFrame.Stop.MouseButton1Click:Connect(function()
	if isRadioGamepass then
		bin.RadioFrame.Title.Text = ""
		RS.RadioEvent:FireServer("StopSong")
	end
end)

solution 1: you can use sound service, and play from there whenever you need to play it

solution 2: when the character dies, you can clone a body part of the character into the workspace… put the sound effect in it and play it, so the part is not lost and plays in the sound
hope i helped :slight_smile:

I dont understand the 2 solution bc if I put one part inside the workspace playing with a sound the max distance dont gonna work so good. and the solution 1 can works bc If could put it inside the Player I guess? (not the character)

yeah both works , i tested it smile emoji

So I can put the audio on the player?

if you put it in player it may not work, put it in sound service is the best solution for me, best place to store sounds

local ss = game:GetService("SoundService")

but the audio is inside the radio and the radio get cloned in the player character.

then , you should wait to player to respawn with : but before you do that , clone the audio

player.CharacterAdded:Wait()

and then set the clone parent to the newcharacter

audio.Parent = player.Character

but when the player character get removed a new one get cloned so that audio get removed and other get cloned again.

before we wait until character spawns , we will clone the audio… character only removes when it respawns.

I dont know if that will works but I will try to find one way.