Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Passcode GUI won't work?

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

6 comments

0

Are you getting any errors in Output?

0

Sorry for the late reply, There is the picture of the OutPut: http://prntscr.com/6199lk

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

0

Is the "Code Gui" object named "CodeGUI", no space, or "Code GUI" with the space?

0

No space.

0

I don't know why that's erroring then. If your gui is named "CodeGUI" and not "Code GUI", this should be working.

1 answer

✓ Accepted answer

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.

6 comments

0

You can call me dumb but What do you mean by else block?

1

The block of code between 'else' on line 18 and 'end' on line 22.

0

I wanted to use the first code you gave me. But It still does not work.

0

Sorry for the late reply, There is the picture of the OutPut: http://prntscr.com/6199lk

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 

0

Hello??

This discussion is preserved as it was. New answers, comments, and votes are closed.