I have assigned the letter “T” to focus on a TextBox using UserInputService, and it works. However, if you are focused on the TextBox and you press Enter to lose its focus, pressing “T” no longer properly focuses on the TextBox. Does anyone know how to fix this?
local UserInputService = game:GetService("UserInputService")
local ChatFrame = script.Parent
local MsgBox = ChatFrame:WaitForChild("MsgBox")
UserInputService.InputEnded:Connect(function(input, GameProccessedEvent)
if not GameProccessedEvent then
if input.KeyCode == Enum.KeyCode.T then
MsgBox:CaptureFocus()
end
end
end)
When I joined your test place it was broke just like you said. The problem is focus is not being returned, I had to click the screen then press T for it to work again. Can’t pinpoint the problem with this script alone.
The problem here is that it doesn’t lose focus when you press the Enter button, but instead put inside the textbox as a character so the cursor goes outside the vision. You might want to prevent that from happening by setting MsgBox.MultiLine to false.