Login System Error!

Hello, I am FriendlyBuilder24 and I have recently made a Login System for my Admin Panel but something is wrong. When I enter the correct information on the Login and press the Login Button it doesn’t work!

(tried to show a video but didn’t work)

Can someone please help me fix this problem? My script is below and I’ll check Output to tell me if something is wrong!

local login = script.Parent.Parent.LoginButton
local username = login:FindFirstChild(“username”)
local token = login:FindFirstChild(“token”)

script.Parent.MouseButton1Click:Connect(function()
if username.Text == “Administrator” and token.Text == “Admin Panel” then

	local panel = script.Parent.Parent.Parent.panel
	panel.Visible = true
	script.Parent.Text = "Login Successful!"
	wait(2)
	script.Parent.Visible = false
	script.Parent.Parent.title2.Visible = true
else
	script.Parent.Text = "Invalid"
	wait(2)
	script.Parent.Parent.title2.Visible = false
	script.Parent.Visible = false
end

end)

Edit:
12:59:16.519 - Players.FriendlyBuilder24.PlayerGui.Admin Panel.login.LoginButton.LocalScript:6: attempt to index nil with ‘Text’

Line 6 is the part where it says if username.Text == “Administrator” and stuff

1 Like

I don’t really know what the problem is with the code, but there is a MAJOR security flaw in your system.

Make sure to check if the text is correct on the server and use a Remote Function to send both of the text inputs and return a value from the server and then tell if the login was successful or not.

This is because an exploiter could easily get into the local script and find what the text needs to be in order to login :slight_smile:

1 Like

That doesn’t really help with the code issue, but thank you for the suggestion. :slightly_smiling_face:

You are using :FindFirstChild but nothing called username or token exist. So :FindFirstChild returned nil.

I have a username button called “username” inside of login and a token that is named “token” inside of login so are you sure?

Try :WaitForChild and check capitalization

Alright, thank you for the help!