I was just wondering is it possible to remove an object from an array through collision this is what I have so far but through collision it deletes half of the objects from the array/table
local function chomp(event)
if event.phase == “ended” then
if event.object2 == head then
print(#allPeople… " number before")
for i = 1, #allPeople do
local onePeople = allPeople[i]
if (onePeople and onePeeps.x) then
onePeople :removeSelf()
table.remove( allPeople, i )
end
end
print(#allPeople… " number after")
updateScore()
xpUp()
timer.performWithDelay(2000, delaySpawn, 1)
end
end
end
Runtime:addEventListener(“collision”, chomp) [import]uid: 87730 topic_id: 36176 reply_id: 336176[/import]