This breaks after table.remove() calls once. No idea why it does, and I don’t remember table.remove() ever breaking loops before.
local HitEnemies = workspace:GetPartBoundsInBox(CF, Size, OP)
for i,Enemy in pairs(HitEnemies) do
if (Stage.Type == "Ground") and (Enemy.Traits:GetAttribute("Flying")) or (Enemy.Traits:GetAttribute("Summon")) then
table.remove(HitEnemies, table.find(HitEnemies, Enemy))
end
end
The if-statement is not the issue. The loop legit just stops after table.remove() does anything.
Just adding on, it’s also redundant to call table.find during an iteration when you’re already given the index of the value you’re trying to remove - substitute it with the i variable, otherwise you’re running two iterations to remove it, one with the generic for that you’re already doing and the other that table.find does.