Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how would i detect if i took damage?

Asked by 3 years ago

how would i detect if i took damage?

2 answers

Log in to vote
1
Answered by 3 years ago

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).

0
ah ok tq ShrynxTube 7 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You could also do

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

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

Answer this question