Hello everyone. I have been working on a script which requires the use of table.remove alot. I decided to work on a sort of table.remove mass function which grabs all the arguments and removes them. However when I use it only 2 out of the 4 args are removed. I have been working on it but I can’t seem to find the issue. Any help would be great.
local Haircuts = {"DandyTrim",
"StarTrim",
"LaReineTrim",
"KabukiTrim",
"PharoahTrim",
"MatronTrim",
"DebunteTrim",
"HeartTrim",
"DiamondTrim"
}
local function ToRemove (tbl,...)
local args = {...}
for i,v in ipairs(tbl) do
if table.find(args,v) then
print(v)
--only finds 2 matching
table.remove(Haircuts,i)
end
end
end
ToRemove(Haircuts,"MatronTrim","DebunteTrim","HeartTrim","DiamondTrim" )
warn(#Haircuts) --only 2 removed out of 9 even after we gave 4 arguments