Table.remove problem

Hello, im having a trouble to use table.remove i know i need to target position in a table to get that one removed but look here:

local ThatTable = {[1] = { ["id"] = { ["id"] = 111,["coords"] = { ["z"] = 63.21,["y"] = 597.54,["x"] = -159.64,} ,["level"] = 0,["allowed"] = true,} ,} ,
[2] = { ["id"] = { ["id"] = 222,["coords"] = { ["z"] = 652.19,["y"] = 1385.11,["x"] = 1032.97,} ,["level"] = 0,["allowed"] = false,} ,} ,
[3] = { ["id"] = { ["id"] = 333,["coords"] = { ["z"] = 121.19,["y"] = 3385.01,["x"] = 5033.17,} ,["level"] = 0,["allowed"] = false,} ,} ,
[4] = { ["id"] = { ["id"] = 444,["coords"] = { ["z"] = -121.00,["y"] = 5315.31,["x"] = 235.67,} ,["level"] = 0,["allowed"] = false,} ,} ,} 

I want to target position [3] but im having only ["id"] = 333, how i can use that to use table.remove properly? I was thinking i could make something like:

for i=1, #ThatTable, 1 do
		if ThatTable[i].id.id == 333 then
		table.remove(ThatTable, ???)
		end
end

table.remove(table,row)
So this case you use table.remove(ThatTable, i)

If you use for k, v loop then it’s table.remove(ThatTable, k)

Or if you just want to change the data to nothing then ThatTable[i].id.id = nil

1 Like

I’ve made an example from the comment of @Epri

for k,v in pairs(ThatTable) do
   if(v['id']['id'] == 333) then
       table.remove( ThatTable,k)
   end
end

Edit: Changed Command to comment :joy:

2 Likes

Thank you :slight_smile:
Simpler than I thought hehe