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

Password Accessable Gui (Keys in a table) [help plz?]

Asked by 4 years ago

Hello, basically I am making a gui that can be accessed if an administrator player had the right password. I have a table along the lines of:

local Keys = {
    "Key1"
    "Key2"
    "Key3"
}

and I try to access it through a TextButton, and a TextBox but it doesn't work.

If I put 'Key1' in the TextBox for example (since it's in the 'Keys' table) and the script under the TextButton is:

script.Parent.MouseButton1Down:Connect(function()
    if script.Parent.Parent.TextBox.Text == Keys then
        print("Thingy worked lolz")
    else
        print("Thingy not worked lolzn't")
    end
end)

It doesn't work. I am not the best Roblox LUA scripter and this code may be entirely wrong but it would be much appreciated if a fellow forum member were to help explain to me what I have done wrong and how to fix it. I feel it's something with the table and I may have scripted it wrong in the TextButton, but I don't know. Any and all help will be much appreciated, Thanks a bunch!

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You'd have to use a for i, in pairs loop. It will loop through all the keys and check if the text is equal to one of the keys.

local Keys = {
    "Key1",
    "Key2",
    "Key3"
}

script.Parent.MouseButton1Down:Connect(function()
    for _, key in pairs(Keys) do
        if script.Parent.Parent.TextBox.Text == key then
            print("Thingy worked lolz")
        else
            print("Thingy not worked lolzn't")
        end
    end
end)
0
ohhh thanks so much Its_Monkey 27 — 4y
0
No problem. Feel free to mark my answer as the answer to the question. youtubemasterWOW 2741 — 4y
0
this is easily exploitable, i recommend server-siding the login. VitroxVox 884 — 4y
0
ok so I understand it's unsecure, because this is just a test. Anyway I am having a problem. for my table Keys only Key3 works, and Key1, and Key2 dont work. Its_Monkey 27 — 4y
0
I edited it. You forgot the comma's on the Keys table. youtubemasterWOW 2741 — 4y
Ad

Answer this question