I’m using the HealthChanged event to trigger a function that puts the player into Ragdoll mode when they take 10 or more damage. However, whenever it fires, it keeps firing over and over again until the player heals to above 90 health. Is there a better event to trigger this function so that it only fires once?
Here’s the script:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local humanoid = char.Humanoid
local currentHealth = humanoid.Health
humanoid.HealthChanged:Connect(function(health)
local change = math.abs(currentHealth - health)
if change > 10 then
char:WaitForChild("IsRagdoll").Value = true
wait(3)
char:WaitForChild("IsRagdoll").Value = false
end
end)
end)
end)