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

Any way to filter out chat for a keyboard command?

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?

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

2 comments

1

Works great! I could not find this property to check if the user is chatting, thank you!

0

No problem, glad I could help!

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