Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I change the sound that plays when a player dies?

local death = script.Parent:WaitForChild("HumanoidRootPart"):WaitForChild("Died")
death.SoundId = workspace:WaitForChild("Ding Ding!").SoundId

This is a LocalScript in StarterCharacterScripts. It works in studio but not in team test.

1 answer

✓ Accepted answer

First of all, make sure you commit scripts that you edited under the "Drafts" tab which can be found under "View" in the top ribbon when in team create.

Second of all, since the sound is under the character model, which is in workspace. You will need to use a Serverscript not a local one, because that sound plays on the server side, meaning everyone can hear that sound, not just the player that died.

That being said, we can use the PlayerAdded event of the "Players" service, and then the CharacterAdded event of the player object in order to change the SoundId of the death sound everytime the player respawns.

So it's going to look something like this:

Serverscript - Place it in "ServerScriptService"

game.Players.PlayerAdded:Connect(function(Player) -- everytime a player joins do what's below
	Player.CharacterAdded:Connect(function(Character) -- if player respawns do what's below
		local diedSound = Character:WaitForChild("HumanoidRootPart"):WaitForChild("Died")
		diedSound.SoundId = workspace:WaitForChild("Ding Ding!").SoundId
	end)
end)

Hope I helped! If you have any questions please let me know.

This discussion is preserved as it was. New answers, comments, and votes are closed.