When I try to get all the elements out of the board, I only get one

Information

Hello my name is Sandessat, and I’m new to LUA.

Recently I asked myself, can I make a login system with Roblox Studio through tables?

I tried, but when I did, something went wrong.

Video

What I’m trying to say in the video is that when I put the FIRST word of the table in the textbox I get that it’s FALSE, but it should be TRUE because it’s in the table.

Code

-- IMPORTANT TABLES
local customersTBL = {"AA", "BB"}

-- VARIABLES
local testingLabel = script.Parent.Parent.Parent.Parent.testingLabel
local inputTextbox = script.Parent.Parent.Parent.textboxFrame.textBox

-- SETTINGS
script.Parent.MouseButton1Click:Connect(function()
	for i, value in pairs(customersTBL) do
		if value ==  inputTextbox.Text then
			testingLabel.Text = "Account Validation: TRUE"
		else
			testingLabel.Text = "Account Validation: FALSE"
		end
	end
end)

I don’t know if I’m wrong in the code or if I’m right, anything leaves your question or answer below and I’ll see it!

You’re checking if each value is equal to what you typed. That means that the text will only reflect whether it’s equal to the last one you check against, since the last one will overwrite whatever the text was before. The easiest way to fix this would be to break after setting the text to true. (break will stop the loop)

4 Likes

Okay, I’ll see if it works, thanks for your reply! :slight_smile:

It’s working, thank you so much!!! :heart:

1 Like