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

why is my Humanoid.HealthChanged not running?

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

✓ Accepted answer

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

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