How to remove all 'nil' values from an array?
snippet in lua

How to remove all 'nil' values from an array?

user9105

function destroy()
    local tbl = {}
    for I = 1, #Objects do
        if(DontDestroyThese[Objects[I]] ~= nil) then
            table.insert(tbl, Objects[I])
        end
    end
    Objects = tbl
end