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

Annoying bug that happens when capturing focus on a textbox?

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

local uis=game:GetService("UserInputService") --Getting UserInputService

uis.InputBegan:connect(function(key) --When a player presses a button on the keyboard
if key.KeyCode==Enum.KeyCode.Slash then --if they pressed enter
script.Parent.Box:CaptureFocus()
end
end)

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

✓ Accepted answer

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 :)

local uis=game:GetService("UserInputService") --Getting UserInputService

uis.InputBegan:connect(function(key) --When a player presses a button on the keyboard
if key.KeyCode==Enum.KeyCode.Slash then --if they pressed enter
wait()
script.Parent.Box:CaptureFocus()
end
end)

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