Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
Edited 4 years 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
LuaDLL 253 Moderation Voter
4 years ago
Edited 4 years 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 — 4y
0
np LuaDLL 253 — 4y
Ad

Answer this question