Self explanatory really, I have a UserInputService that has a gui pop up when a key is pressed. This is annoying when a player is chatting. Any way around this?
✓ ANSWER ACCEPTED
Any way to filter out chat for a keyboard command?
1 answer
✓ Accepted answer
All you need to do in your code is check whether the TextBox for the chat is currently selected or not, and run your code accordingly. To accomplish this, we simply define a variable for the TextBox, and in the UserInputService event, do something like this:
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local chatBox = player.PlayerGui:WaitForChild("Chat"):FindFirstChild("ChatBar", true)
uis.InputBegan:connect(function(inputObject)
if not chatBox:IsFocused() then
print("This code prints this message!") --Your code here
end
end)
I believe that this code should work for your purposes. If you have any further questions I am happy to answer them, just let me know. Hope this helps :)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Works great! I could not find this property to check if the user is chatting, thank you!
No problem, glad I could help!