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

Help with a login system for a admin gui??? Dealing with arrays??

Asked by 7 years ago

ok so i am trying to make a admin gui which has nothing done except the login page so i am mostly looking help for searching through a whole array with a conditional statement im not fully sure how to do this I looked at the roblox wiki and that didnt help! Here is my code:

local LPlayer = game.Players.LocalPlayer
local users = {"billybob","CharlieBrown","Player1"} -- for testing but Player1 is for studio
local password = "NocTernL"

--setting up shortcuts
local loginpage = script.Parent.LoginPage -- part of the Gui


function login()
    if users[LPlayer.Name] == nil then -- this is where i think the problem is
        LPlayer.Character.Humanoid.Health = 0 -- Just so u know this part was for testing it
    end
end

loginpage.login.MouseButton1Click:Connect(login) --just calling it

Thanks!

0
This is a commen mistake i see in questions. It is :connect, not :Connect SH_Helper 61 — 7y

1 answer

Log in to vote
2
Answered by 7 years ago
Edited 7 years ago

Either set your table up like

{
     ["Name"] = true;
     ["Name2"] = true;
}

to have it work with the code you have now, or loop through the table and look if the member is valid instead of the index:

for index,member in pairs(names) do -- index will be a number so you can't index by table[name]
     if member == name then
          return true
0
ok im not at home so i cannot test but my question is if there is no value matching in the whole table then it executes code but I dont want to have it execute the code until it has scanned through the whole table? thanks for showing me how to go through whole table but i still need a bit more help to understand it. Bo2master01 0 — 7y
Ad

Answer this question