local Humanoid = game.Players.LocalPlayer.Character.Humanoid.Health
✓ ANSWER ACCEPTED
How do we play a sound when a player takes damage?
1 answer
✓ Accepted answer
Make sure to add an intvalue and rename it to "recentUserHP" Make sure it's parented to script1
local script1 = script.Parent -- Defining the function
local frame = script1.Frame
local sound = Instance.new ("Sound",script1)
sound.SoundId = "http://www.roblox.com/asset/?id=386232234"
local humanoid = game.Players.LocalPlayer.Character.Humanoid
--this function below fires whenever the humanoid's health changes.
--It also gets the health of the user at that time. (inside the parentheses)
humanoid.HealthChanged:connect(function(health)
if script1.recentUserHP.Value > health then
--this asks if the most recent HP logged is higher than the users current HP
sound:Play()
elseif script1.recentUserHP.Value < health then
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Please make an attempt before asking a question,
i did