01 | for i, v in pairs (CurrentEnemies) do |
02 | v.Humanoid.HealthChanged:Connect( function () |
03 | if v.Humanoid.Health < = 0 then |
04 | print ( "healthlow" ) |
05 | --Add Coin Event |
06 | table.remove(CurrentEnemies, v) |
07 | Remaining.Value = Remaining.Value - 1 |
08 | v:Destroy() |
09 |
10 | end |
11 | end ) |
12 | end |
runs through current enemies and checks if they died
but the .HealthChanged isnt firing.
Try using the get property changed signal:
01 | for i, v in pairs (CurrentEnemies) do |
02 | v.Humanoid:GetPropertyChangedSignal( "Health" ):Connect( function () |
03 | if v.Humanoid.Health < = 0 then |
04 | print ( "healthlow" ) |
05 | --Add Coin Event |
06 | table.remove(CurrentEnemies, v) |
07 | Remaining.Value = Remaining.Value - 1 |
08 | v:Destroy() |
09 |
10 | end |
11 | end ) |
12 | end |