For loop ignore list

How would I create a ignore list for a For loop? let’s say I’m trying to get a list of things in a table how would I ignore a string in that table and print out the rest?

local Table = {"Apple","Orange","Tree","Paper","Mouse"} --Ignore Apple and paper

for i,v in pairs(Table) do
	print(v) -- Print out the rest
end
1 Like

Simple. Just make an ignore list, iterate through the main list, and check if value matches a part of the ignore list.

local Table = {"Apple","Orange","Tree","Paper","Mouse"}
local Ignore = {"Apple","Paper"}

for i, v in pairs(Table) do
    if table.find(Ignore, v) then
        print(v .. " is a part of the Ignore list")
    end
end
3 Likes

nevermind lol i realized thats different :frowning: sorry xd

How would I print out the items that are not in the ignore list?

Replace

if table.find(Ignore, v) then

with

if not table.find(Ignore, v) then

Sorry, I don’t really know how to explain it, it’s really late, 1 AM, and I’m sleepy.

1 Like