Removing table value without knowing position

Hey devs,

I’m trying to set a table value to nil (because I won’t know it’s position, everything will be randomly generated kinda) but I dont know how or what to do, because this doesn’t remove it…

local queues = {
["1"] = {765, 9837},
["2"] = {432, 567}
}
local arguments = {Queue = "1"}
for i,v in pairs(queues[arguments.Queue]) do
	if v == 765 then
		v = nil
	end
end

for i,v in pairs(queues[arguments.Queue]) do
	print(v) -- this still print's 765
end

(So sorry this isn’t a very professional post, I’m very tired at the moment.)
(Everything is also very automated, made it manual to debug, but I cannot figure out anything either.)

Your idea is good, but you have to remove the element by it’s index. Right now you’re just nullifying the value returned by pairs

if v == 765 then
	queues[arguments.Queue][i] = nil
end
1 Like