How do you check if instance is in a table?

You can use table.find to search through the table and find specific value
If you want to check if an instance is in a table you can do this:

local instances = {}
local instance = ...

if table.find(instances, instance) then
    -- Instance is in the table "instances"
end

This function also searches through each value in the table though, I’m not sure if it can be done more efficiently unless the table was setup in some weird way. Performance also depends on how large the table is and how frequently you are going to be using table.find

6 Likes