How to detect when chat box is selected?

I am trying to detect inputs using UserInputService, but I want to ignore some inputs while the player is typing a message in chat or in a text box so that they don’t accidentally trigger something trying to type a message. I can’t find any solutions to this on the DevHub.

2 Likes

Consider this reply I made a while ago.

1 Like
--//Services
local UserInputService = game:GetService("UserInputService")

if UserInputService:GetFocusedTextBox() then
	print("Player is in a text box")
else
	print("Player is not in a text box")
end
7 Likes

This will trigger the event for all TextBoxes, not just the chat bar.

In order to achieve your solution @zykobyte, you must check the name of the TextBox currently being typed in. Consider the link I replied.

2 Likes

Mine is what they want, re-read the post.

1 Like

Ah I misread, apologies for my confusion.

2 Likes