Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Passcode GUI won't work?

Asked by 9 years ago

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

0
Are you getting any errors in Output? adark 5487 — 9y
0
Sorry for the late reply, There is the picture of the OutPut: http://prntscr.com/6199lk Chillu4 0 — 9y
0
The script above is in a LocalScript named "LocalScript" and It is placed in the StarterPack. There is another script inside the GUI which only makes the GUI visible and makes the Player's walkspeed to 0 Chillu4 0 — 9y
0
Is the "Code Gui" object named "CodeGUI", no space, or "Code GUI" *with* the space? adark 5487 — 9y
View all comments (2 more)
0
No space. Chillu4 0 — 9y
0
I don't know why that's erroring then. If your gui is named "CodeGUI" and not "Code GUI", this should be working. adark 5487 — 9y

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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.

0
You can call me dumb but What do you mean by else block? Chillu4 0 — 9y
1
The block of code between 'else' on line 18 and 'end' on line 22. adark 5487 — 9y
0
I wanted to use the first code you gave me. But It still does not work. Chillu4 0 — 9y
0
Sorry for the late reply, There is the picture of the OutPut: http://prntscr.com/6199lk Chillu4 0 — 9y
View all comments (2 more)
0
Thanks but every seems to be fine but the output tells "CodeGUI is not a vaild member of PlayerGui" The Gui's name is Code GUI . Here's the output. http://prntscr.com/62i9se  Chillu4 0 — 9y
0
Hello?? Chillu4 0 — 9y
Ad

Answer this question