PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Humanoid.HealthChanged

Humanoid.HealthChanged

Oct 01 2018, 1:57 AM PST

The following example determines the change in health, printing it to the output. It will only work in a LocalScript.

local humanoid = game.Players.LocalPlayer.Character.Humanoid
local currentHealth = humanoid.Health
humanoid.HealthChanged:Connect(function(health)
	local change = math.abs(currentHealth - health)
	print("The humanoid's health "..(currentHealth > health and "decreased by " or "increased by ")..change..".")
	currentHealth = health
end)