Hello, everyone. I am currently trying to make a pain script that will play a pain noise upon taking a certain amount of damage, as long as your health isn't 0. Also, there are no errors in the output. My code is listed below and help will be much appreciated.
Script is located in game.StarterPlayer.StarterCharacter, so it's already inside of the character upon the game starting.
--//Pain noises script
CP = game:GetService("ContentProvider")
CP:Preload("rbxassetid://155675172") -- Weak
CP:Preload("rbxassetid://455247628") --Medium
CP:Preload("rbxassetid://455247407") -- Major
local currHealth = script.Parent.Humanoid.Health
local Dam = 0
--------------------------------------------------------------------
MinorPain = 20
MediumPain = 25
Major = 45
function checkHealth()
--------------------------------------------------------------------
if currHealth - Dam < MinorPain then --Only plays when you take less than 20 damage
script.Parent.Weak:Play()
wait(1)
script.Parent.Weak:Stop()
--------------------------------------------------------------------
if currHealth - Dam < MediumPain > MinorPain then --Only plays when you take more than 25 damage
script.Parent.Medium:Play()
wait(1)
script.Parent.Medium:Stop()
--------------------------------------------------------------------
if currHealth - Dam < Major > MediumPain then --Only plays when you take more than 45 damage
script.Parent.Major:Play()
wait(1)
script.Parent.Major:Stop()
--------------------------------------------------------------------
end
end
end
end
while true do
wait(0)
checkHealth()
end
