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

Streamlining UserIds into List?

Asked by
Moxeh 84
10 years ago

How would I make a sort of permissions list instead of adding "or 0"? I want to make it so there is a list of user ids, if it is on the list it makes a gui visible. This isn't the whole script and it all works, just want more streamlined functionality.

if gui.id.Value == 16212258 or 0 then
        gui.Frame.Visible = true

1 answer

Log in to vote
0
Answered by 10 years ago

Using a table that contains the list of userIds you could achieve this, by either doing the following

local list = { --Setting the index of the table that is the same as the userId to true
    [12345678] = true; -- And listing each as such, if you wish to avoid for loops
    [87654321] = true;
}
if list[userId] then
    -- action
end

or

local list = {12345678,87654321} -- Or holding a list of the userIds
if (function() for i, v in pairs(list) do if userId == v then return true end end return false end)() then
    -- action
end
Ad

Answer this question