Hello, I would like to know how to make a script that plays a sound when the player has been damaged by anything, like in the script you have a roblox id and you enter the of number of the search number of the sound. Something like when damaged play sound? Thanks for helping me.
COMMUNITY QUESTION
How do i make a script that plays a sound when my player has been damaged?
1 answer
This is a help forum, not a request site. However I would still try using a script along the lines of:
-- StarterCharacterScript
hum = script.Parent.Humanoid
last = hum.Health
mysound = Instance.new("Sound", script.Parent)
mysound.SoundId = 1337 -- Sound ID
hum.Changed:Connect(function()
if hum.Health ~= last and hum.Health < last then
print("i've been damaged!")
mysound:Play()
end
last = hum.Health
end
This script checks to see if the health is less than it was before. If it works let me know please!
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You should use the HealthChanged event instead of the Changed event