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.