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

Annoying bug that happens when capturing focus on a textbox?

Asked by 8 years ago

So i'm using a LocalScript with the simple code:

1local uis=game:GetService("UserInputService") --Getting UserInputService
2 
3uis.InputBegan:connect(function(key) --When a player presses a button on the keyboard
4if key.KeyCode==Enum.KeyCode.Slash then --if they pressed enter
5script.Parent.Box:CaptureFocus()
6end
7end)

The code works, but when it captures focus, the text is automatically set to "/" (slash) when the key is hit.

Can anyone help me fix this? thanks

1 answer

Log in to vote
1
Answered by
Cesire 45
8 years ago

Have you tried using wait(), If it doesn't work mess around with it a bit. If you want to wait one second you'd say wait(1) in case you wonder :)

1local uis=game:GetService("UserInputService") --Getting UserInputService
2 
3uis.InputBegan:connect(function(key) --When a player presses a button on the keyboard
4if key.KeyCode==Enum.KeyCode.Slash then --if they pressed enter
5wait()
6script.Parent.Box:CaptureFocus()
7end
8end)
Ad

Answer this question