Why is my Keypad not working?

I’m trying to make a Keypad door for my game, but the problem is that, even when I type the code correctly, it doesn’t work for some reason.
I can’t find anything on the web or in the forums, and I don’t know what to do.

local TextBox = script.Parent
local Password = game:GetService("Workspace"):FindFirstChild("Password", true)

local function focusLost(enterPressed)
	if enterPressed then
		if Password and TextBox.Text == Password.Value then
			print("Correct!")
		else
			print("Incorrect!")
			print(Password.Value)
		end
	end
end

TextBox.FocusLost:Connect(focusLost)
-- The prints are for debugging.

The password is an IntValue inside a model, if that helps.

you have a global workspace already so don’t do that anymore please.
What is the point of password if anyone can access and see it so easily?

Why are you using FindFirstChild? and why is it recursive?

You sure its a client context and not a server?

Also obviously it will not work;
You have to cast it into string

local TextBox = script.Parent
local Password = workspace:WaitForChild("Password")::IntValue

local function focusLost(enterPressed: boolean):()
	if enterPressed==false then return end
	if TextBox.Text == tostring(Password.Value) then
		print("Correct!")
	else
		print("Incorrect!")
		print(Password.Value)
	end
end

TextBox.FocusLost:Connect(focusLost)
-- The prints are for debugging.
1 Like

I don’t know what you mean by “see easily.” Do you mean when the password is printed into the output?

Also, I didn’t know how tostrings worked until I saw this thank you

that and exploiters see it and assidental errors making it to be seen by users.

Such systems must be using RemoteEvent/RemoteFunction for communication and storing data in non assesible to users containers.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.