Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How to find if an value exists as in a lua table?

Asked by 1 year ago
Edited 1 year ago

I would like to know how can a script find if a value exists in a Lua table, something like

luatable = {"abc", "cba", "bab"}
--example: wanted to know if something in workspace with a name of any of those values exists..

How can I do it?

1 answer

Log in to vote
1
Answered by
AIetheo 236 Moderation Voter
1 year ago
Edited 1 year ago

You Could Use A For Loop To Search Through The Descendants Of Workspace Or Whatever Your Looking For

Example

local Table = {"abc","bca","cab"}

for i,v in pairs(workspace:GetDescendants()) do -- Will Go Through Everything in the workspace
    if Table[v.Name] then -- If the name of the object is in the table
        -- Do Rest
    end
end
0
Thank you! Igoralexeymarengobr 365 — 1y
0
np AIetheo 236 — 1y
Ad

Answer this question