I’m currently trying to create a custom chat service for my game and there is a small bug that appears. I use the default keybind of “/” to force focus onto the chat TextBox which works well and the whole chat system is functional apart from one slightly annoying bug:
Because I’ve used the keybind “/” to force the player to chat, the text character appears in the TextBox as follows:
Here is the client source:
game:GetService("UserInputService").InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Slash then
if PlayerGui.Radio.State ~= "Off" then
PlayerGui.Radio.Frame.TextBox:CaptureFocus()
end
end
end)
Is there any way to stop the slash appearing after it’s focused? Any help would be appreciated,
Thanks -Tom
So it detects the keypress when the slash key is released.
You may also want to implement gameProcessedEvent so the text box code isn’t triggered if the user presses “/” while the text box is focused.
game:GetService("UserInputService").InputEnded:connect(function(inputObject, gameProcessedEvent)
if gameProcessedEvent == false then
if inputObject.KeyCode == Enum.KeyCode.Slash then
if PlayerGui.Radio.State ~= "Off" then
PlayerGui.Radio.Frame.TextBox:CaptureFocus()
end
end
end
end
end)