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!
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)