while true do
if game.Players.LocalPlayer.Character.Humanoid:TakeDamage() then
script.Parent.Parent.Sounds.Hurt:Play()
end
end
✓ ANSWER ACCEPTED
Problem with this script?
1 answer
✓ Accepted answer
The TakeDamage method is used to well, take damage. You would put a number as a parameter and the Humanoid would take damage. You need to use the Changed event.
game.Players.PlayerAdded:connect(function(p)
repeat wait() until p.Character -- You could also use the CharacterAdded event. I for some reason did it this way
hum = p.Character.Humanoid
old = hum.Health
hum.Changed:connect(function()
if (hum.Health < old) then
script.Parent.Parent.Sounds.Hurt:Play()
old = hum.Health
end
end)
end)
The above script was actually tested and should work perfectly.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
:TakeDamage(n) is a method that takes damage n from the Humanoid, not checks if damage was taken.