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

why is my Humanoid.HealthChanged not running?

Asked by 3 years ago
for i, v in pairs(CurrentEnemies) do
    v.Humanoid.HealthChanged:Connect(function()
        if v.Humanoid.Health <= 0 then
            print("healthlow")
            --Add Coin Event
            table.remove(CurrentEnemies, v)
            Remaining.Value = Remaining.Value - 1
            v:Destroy()

        end
    end)
end

runs through current enemies and checks if they died

but the .HealthChanged isnt firing.

1 answer

Log in to vote
1
Answered by 3 years ago

Try using the get property changed signal:


for i, v in pairs(CurrentEnemies) do v.Humanoid:GetPropertyChangedSignal("Health"):Connect(function() if v.Humanoid.Health <= 0 then print("healthlow") --Add Coin Event table.remove(CurrentEnemies, v) Remaining.Value = Remaining.Value - 1 v:Destroy() end end) end
Ad

Answer this question