Killing player after sound is done

Hello developers, quick question here:

How do I kill the player and destroy the sound once the sound is fully finished/ over?

Here’s the code (without humanoid.health = 0):
local sound = Instance.new("Sound") sound.Parent = workspace.PARALOL.Torso sound.SoundId = "rbxassetid://10419979590" sound:Play() sound.Ended:Wait() sound:Destroy()

Thanks, -Para

(I am aware this is very simple code, but I am mostly a builder, and I have no one helping me with this game right now, so I resorted to this.)

Try doing

local Sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://10419979590"
sound:Play()
sound.Ended:Wait()
sound:Destroy()
workspace.PARALOL.humanoid:TakeDamage(math.huge)
--Or 
workspace.PARALOL.PrimaryPart:Destroy()
2 Likes

instead of doing sound:Destroy() you could do sound:Stop()
I think its killing the player because the sound is a parent of the tor

I’m using Sound:Destroy to clear debris or unnecessary audios inside the game. The game is pretty heavy on graphics so adding more unused audios can lag (according to my friend).

1 Like