local Tab = {"Apple","Apple","Orange","Apple","Apple","Apple","Banana","Apple","Apple","Pear","Apple"}
while table.find(Tab,"Apple") do
table.remove(Tab,table.find(Tab,"Apple"))
end
print(Tab)
local mytab = {"Apple","Banana","Apple","Carrot","Banana","Apple","Melon"}
for index,value in pairs(mytab) do
if value:match("Apple") then
table.remove(mytab,index)
end
end
for _,v in pairs(mytab) do
print(v)
end
Unfortunately since my table is over 100 elements long, I have to do that function multiple times for it to work. But when I do that it works like a charm. Thanks!
I would probably do this as it won’t iterate through the entire array every time (technically it would, but not in Lua). But both are probably fine as long as this isn’t happening rapidly and constantly.