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