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

Sound on Death?

I have been trying to make this sound play on death. I have tried everything with my meager knowledge of scripting and come up short. Does anyone have any ideas? The code block is the on death function, but i cannot understand anything related to sound. Anyone mind helping me add the play sound function?

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			print(player.Name .. " has died!")
		end)
	end)
end)

1 answer

✓ Accepted answer

Try this!

SID = 157707359 -- Sound ID goes here if you ever need to change it.

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            local s = Instance.new("Sound", player.Backpack)
              s.SoundId = "http://www.roblox.com/asset/?id="..SID
              s:Play()
        end)
    end)
end)

3 comments

0

Alright I am going to try this

0

You need a medal trytoeatme

0

Thanks! Glad it worked, happy to help you.

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