Why isn't this GUI bind working?
Asked by
8 years ago Edited 8 years ago
01 | local screenGui = Instance.new( "ScreenGui" ) |
02 | screenGui.Parent = script.Parent |
04 | local textLabel = Instance.new( "TextLabel" ) |
05 | textLabel.Parent = screenGui |
06 | textLabel.Position = UDim 2. new( 0 , 0 , 0 , 0 ) |
07 | textLabel.Size = UDim 2. new( 0 , 200 , 0 , 180 ) |
08 | textLabel.BackgroundColor 3 = BrickColor.Green().Color |
09 | textLabel.TextXAlignment = 0 |
10 | textLabel.TextYAlignment = 0 |
14 | textLabel.Visible = false |
16 | local textBox = Instance.new( "TextBox" ) |
17 | textBox.Parent = screenGui |
18 | textBox.Position = UDim 2. new( 0 , 0 , 0 , 180 ) |
19 | textBox.Size = UDim 2. new( 0 , 200 , 0 , 20 ) |
20 | textBox.BackgroundColor 3 = BrickColor.Green().Color |
21 | textBox.TextXAlignment = 0 |
22 | textBox.TextYAlignment = 1 |
26 | textBox.Visible = false |
28 | function onKeyPress(inputObject, gameProcessedEvent) |
29 | if inputObject.KeyCode = = Enum.KeyCode.Tilde then |
30 | textLabel.Visible = true |
31 | textBox.Visible = true |
34 | game:GetService( "UserInputService" ).InputBegan:connect(onKeyPress) |
Everything except for the final paragraph of code is working. Does anyone know what the problem is? Thank you!
EDIT: I've figured out that the tilde is actually the thing causing the problem, not the other commands.