of     1   

UgandaPizzaPolice
#140967373Sunday, July 20, 2014 6:28 PM GMT

I'm making an admin GUI. But there's one thing I need help with: How do I make a modulescript where it reads who's an admin and who's not an admin?
GGGGG14
#140968030Sunday, July 20, 2014 6:34 PM GMT

local AdminModule = {} AdminModule.Administrators = {"Name", "Name2", "Name3", "etc"} AdminModule.IsAdmin = function(Table, User) for Index = 1, #Table do if Table[Index] == User.Name then return true end end end return AdminModule;
UgandaPizzaPolice
#140968186Sunday, July 20, 2014 6:36 PM GMT

@Azureous Thanks.
PalmToFace
#140968506Sunday, July 20, 2014 6:39 PM GMT

@Azure Disgusting... local adminModule = {}; adminModule.administrators = { Name = true; Name2 = true; Name3 = true; etc = true; }; adminModule.isAdmin = function(table, user, bool) if (bool) then if (table[user.Name]) then return true; end; else for i = 1, #table do if (table[i] == user.Name) then return true; end; end; end; end; return adminModule;
UgandaPizzaPolice
#140969043Sunday, July 20, 2014 6:45 PM GMT

One thing: Can the module give the admin gui to the specific user? Let's say the script makes the gui visible since the gui is in the script. How do I make it where It copys the gui to the user who's been picked? Just a quick question.
GGGGG14
#140969047Sunday, July 20, 2014 6:45 PM GMT

@Palm you literally have no idea what you're talking about. A numerical for loop runs three times as fast as your two conditionals + numerical for loops and you're just following what the wiki said, but my function returns if the name is in the table, rather than a useless bool that goes along with it.
PalmToFace
#140969694Sunday, July 20, 2014 6:52 PM GMT

@Azure Please tell me where I am following the wiki? I'm rather... confused... on that part. I was just going to use indexes flat-out, but most people use the hideous for loop, so I decided to add a bit of support for that. If I didn't, it'd be something like this (which is, to my knowledge, more efficient): local adminModule = {}; adminModule.administrators = { Name = true; Name2 = true; Name3 = true; etc = true; }; adminModule.isAdmin = function(table, user) if (table[user.Name]) then return true; end; end; return adminModule;
GGGGG14
#140969708Sunday, July 20, 2014 6:52 PM GMT

@Thread maker -- (This is in a normal script) local requiredMod = require(Workspace.AdminModule); local Gui = blahblah game:GetService("Players").PlayerAdded:connect(function(newUser) if requireMod.IsAdmin(requiredMod.Administrators, newUser) then Gui:Clone().Parent = newUser:WaitForChild("PlayerGui") end end)
GGGGG14
#140969796Sunday, July 20, 2014 6:53 PM GMT

@Palm, yes your second script would be more efficient, but your first had multiple conditionals which are less efficient.
GGGGG14
#140969913Sunday, July 20, 2014 6:54 PM GMT

@Thread maker, I made a typo, it should be 'requiredMod'
PalmToFace
#140969953Sunday, July 20, 2014 6:55 PM GMT

@Azure I have seen many people make less efficient, yet more compatible, scripts. That is simply what I did.
UgandaPizzaPolice
#140971348Sunday, July 20, 2014 7:09 PM GMT

Thanks for the help!
UgandaPizzaPolice
#140976019Sunday, July 20, 2014 8:00 PM GMT

I found a problem: In the server console, the admin script says that "IsAdmin" is a nil value.
UgandaPizzaPolice
#140976615Sunday, July 20, 2014 8:07 PM GMT

Nevermind, fixed it

    of     1