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

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

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

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)

5 comments

0

ohhh thanks so much

0

No problem. Feel free to mark my answer as the answer to the question.

0

this is easily exploitable, i recommend server-siding the login.

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.

0

I edited it. You forgot the comma's on the Keys table.

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