Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how would i detect if i took damage?

how would i detect if i took damage?

2 answers

✓ Accepted answer

You would need to use :GetPropertyChangedSignal()

local health = 100
player.Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	if player.Character.Humanoid.Health < health then
		-- code goes here
	end
	health = player.Character.Humanoid.Health
end)

This will only fire if the humanoid health is LOWERED (aka damaged).

1 comment

0

ah ok tq

You could also do

Humanoid.HealthChanged:Connect(function()
-- code
end

this way you can fire a function whether the health goes up or down

This discussion is preserved as it was. New answers, comments, and votes are closed.