How to detect if player is tying in chat (with new Chat)

I used to be able to use UserInputService.TextBoxFocused, but this doesn’t seem to work with the new chat (it fires Focused when I unfocus from the chat box) so is there a new way to do this?

Solution to this question already states just use GPE or check the Gui? The Gui doesn’t exist under PlayerGui, and GPE also fires for over events (typing in-gamer textboxes)

8 Likes

The chatbar frame is an instance parented to the chat gui that is parented to player gui. So, it should be simple to check for a change in the chat bar, you can do this by:

local playergui=game.Players.LocalPlayer:WaitForChild("PlayerGui")

local ChatGui = playergui:WaitForChild("Chat")
local ChatBar=ChatGui.Frame.ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar
local default_text=CharBar.Text

local isTyping=false

ChatBar:GetPropertyChangedSignal("Text"):Connect(function()
     if ChatBar.Text==default_text then
         isTyping=false
      else
        isTyping=true
        print("player is chatting")
     end
end)

Though this isn’t a complete fix, and I suppose is not a good method to check if player is using the chat, but it works.

I think he means the new CoreGUI chat. I’m thinking indexing all in-game frames and if UIS.GameProcessed exists but no in-game textbox is focused then the player is typing somewhere in CoreGui, likely Chat.

1 Like

Client script:

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(_, GameProcessedEvent)
   if GameProcessedEvent then
       print("Is typing in chat box")
   end
end)

Please read my question fully :confused:

Please read my question fully :confused:

That’s strange though… it should have worked on the new official roblox chat system.

It does work, but it also fires for every other textbox in game, so it’s not seperate

Found the solution

local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local ChatInputBarConfiguration = TextChatService:FindFirstChildOfClass("ChatInputBarConfiguration")
local BubbleChatConfiguration = TextChatService:FindFirstChildOfClass("BubbleChatConfiguration")

local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()

-- Set up TextLabel
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.fromScale(1, 1)
textLabel.Text = ". . ."
textLabel.BackgroundColor3 = BubbleChatConfiguration.BackgroundColor3
textLabel.BorderColor3 = BubbleChatConfiguration.BackgroundColor3
textLabel.BackgroundTransparency = BubbleChatConfiguration.BackgroundTransparency
textLabel.TextColor3 = BubbleChatConfiguration.TextColor3
textLabel.FontFace = BubbleChatConfiguration.FontFace
textLabel.TextSize = BubbleChatConfiguration.TextSize
-- Parent a UICorner to the TextLabel to have rounded corners
local uiCorner = Instance.new("UICorner")
uiCorner.CornerRadius = UDim.new(0,12)
uiCorner.Parent = textLabel

-- Set up Billboard
local typingIndicatorBillboard = Instance.new("BillboardGui")
typingIndicatorBillboard.Enabled = false
typingIndicatorBillboard.Size = UDim2.fromScale(1, 1)
typingIndicatorBillboard.StudsOffsetWorldSpace = Vector3.new(-0,4,0)
typingIndicatorBillboard.Adornee = Character
textLabel.Parent = typingIndicatorBillboard
typingIndicatorBillboard.Parent = LocalPlayer:FindFirstChildOfClass("PlayerGui")

ChatInputBarConfiguration:GetPropertyChangedSignal("IsFocused"):Connect(function()
  -- Enable the typing indicator when the input bar is focused and disable otherwise
  typingIndicatorBillboard.Enabled = ChatInputBarConfiguration.IsFocused
end)
9 Likes

Could you show this working in a gif? You can start a local server in studio with 2 simulated players and record both windows while you demonstrate this

Don’t have time atm to do that, but what Roblox provides would just be purely client side. All I do is fire to server and server fires back to all clients to show the bubble

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.