Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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!

1 comment

0

This is a commen mistake i see in questions. It is :connect, not :Connect

1 answer

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

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.