Hi, I wanted to make a Passcode GUI for my Place. Everything works but when I enter the password and press the enter key, It wont tell that the password is right or and It wont close the GUI if the password is correct. Heres the script so you can see what mistakes i have done. The script is placed in the StarterPack and the script is a LocalScript.
code = "EnterCodeHere" ---------------------------------!WARNING!--------------------------------------------- ---DON'T CHANGE ANYTHING!--- Player = script.Parent.Parent Mouse = Player:GetMouse() codegui = script.Parent.Parent.StarterGui.CodeGUI codeteller = script.Parent.Parent.StarterGui.CodeGUI.Background.PasscodeTeller codetype = script.Parent.Parent.StarterGui.CodeGUI.Passcode.TypeCodeHere function onKeyDown() local key = key.lower() if key:byte() == 13 then -- From this part it stops working... if (codetype == code) then codeteller.Text = "Correct" wait(2) script.Parent.Parent.Character.Humanoid.WalkSpeed = 16 codegui:remove() else codeteller.Text = "Wrong" wait(3) codeteller.Text = "Passcode" end end end Mouse.KeyDown:connect(onKeyDown)
Thanks! -Chillu4
I assume codetype
is a TextBox? Line 13 needs to be:
if (codetype.Text == code) then
I would also suggest adding :
codetype.Text = ""
Before line 19, inside the else block.
EDIT: Better late than never.
Your problem is that the StarterGui
becomes the PlayerGui
when it's actually part of a Player. Rename it to that on lines 6, 7 and 8 to fix that.