I try to make a login script but the script doesn't do the right thing

Information

I’m new to scripting

I made a post about something that had an error previously, but today I was trying to make a login with a name and an ID to have more security, but I get an error when I try to do.

Video

What I try to say in the video, is that the text that the user inserted into the textbox 1, the script should look for the user ID in the customersData folder, but it seems that it does not find it, I need help!

Code

-- IMPORTANT TABLES
local customersNameTBL = {"sabha123"}

-- VARIABLES
local testingLabel = script.Parent.Parent.Parent.Parent.testingLabel
local nameTextbox = script.Parent.Parent.Parent.textboxFrame.textBox
local idTextbox = script.Parent.Parent.Parent.textboxIDFrame.textBox
local insertedCustomer = nil

local customersData = game.ReplicatedStorage.customersData

-- SETTINGS
script.Parent.MouseButton1Click:Connect(function()
	for vN, valueName in pairs(customersNameTBL) do
		if valueName ==  nameTextbox.Text  then
			insertedCustomer = nameTextbox.Text

			if idTextbox == customersData[insertedCustomer].userID.Value then
				testingLabel.Text = "Account Validation: TRUE"
			else
				testingLabel.Text = "Account Validation: INVALID ID / USER NOT FOUND"
			end
			break
		else
			testingLabel.Text = "Account Validation: FALSE"
		end
	end
end)

If you need more information, do not hesitate to contact me!
Please help me, thanks.

1 Like

Hello,

I am not entirely sure on how to fix this problem but you should probably save customer data with IDs on the server, as saving them in ReplicatedStorage would allow exploiters to freely get this data & login with another user’s data.

1 Like

How? Where should I put the folder?

On the ServerStorage in the game?

You should put the data into ServerStorage, then use a RemoteFunction to give the server the login data (so the text that is in the TextBoxes) and verify it on the server, then you can return true/false with the server (depending if the info was right) to display it on the login UI.

Can you tell me the instructions of that please, I already moved the folder to ServerStorage.

Can we get some context to what this is meant to do? If you this is apart of a public server:

  • You are storing all the login info in ReplicatedStorage open for any exploiter to access

  • You are trusting the client, do not do that. Let the client make a request to the server through a RemoteFunction or a RemoteEvent, and then tell the client the response.

  • Move login information to ServerStorage, where only the server can access it making it safe from exploiters. (Remember the client does not have access to ServerScriptService or ServerStorage)

And to answer your question, you are giving a string (text) which is not a player object. What you should do is:

local fPlayer = game.Players:FindFirstChild(nameTextbox.Text)
if fPlayer then
insertedCustomer = gotPlayer
--whatever your code
end

Mind responding with what this is for? If this like an admin panel you do not need any of this lol, the server can just give the client the panel and can just check any requests given in the GUI.

1 Like

Oh, sorry, I’m dunno, I’ll try that, thanks!

EDIT: IT’S WORKING, THANK YOU SO MUCH!!!

2 Likes

No problem, but if you can tell us what this is for your situation can be made so much easier and way more secure.