New TextChatService Inquiry

Hey, I am trying out the new chat system which we are having to migrate to and I can’t seem to figure out how to fix the chat bubble system I have that displays a chat bubble over a players head when they are typing. I have spent 2 hours trying to figure it out and I still am unable to. If anyone could help that would be much appreciated!

Code in ServerScriptService

local Player = game.Players.LocalPlayer
local UserInputService = game:GetService(“UserInputService”)

UserInputService.TextBoxFocused:Connect(function(TextBox)
if TextBox.Name == “ChatBar” then
game.ReplicatedStorage.ToggleTypingBubble:FireServer(true)
end
end)

UserInputService.TextBoxFocusReleased:Connect(function(TextBox)
if TextBox.Name == “ChatBar” then
game.ReplicatedStorage.ToggleTypingBubble:FireServer(false)
end
end)

Code in StarterGui

game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local TypingBubble = script.TypingBubble:Clone()
TypingBubble.Parent = Character.Head
end)
end)

game.ReplicatedStorage.ToggleTypingBubble.OnServerEvent:Connect(function(Player, Toggle)
Player.Character.Head.TypingBubble.Enabled = Toggle
end)

Thanks,
Leo

It looks like UserInputService.TextBoxFocused and UserInputService.TextBoxFocusReleased do not work on TextBox outside of a Player’s PlayerGui. The default Roblox chat is located in a ScreenGui named “ExperienceChat” in CoreGui, which requires plugin level security context.

However, under TextChatService there is a child ChatInputBarConfiguration (Name matching ClassName) which has a property called “IsFocused” which changes to true when the player has the chat TextBox focused and false when the player does not. Listening for whether the player has the chat TextBox focused is as simple as:

local TextChatService = game:GetService("TextChatService")

TextChatService.ChatInputBarConfiguration:GetPropertyChangedSignal("IsFocused"):Connect(function()
	
	local isFocused = TextChatService.ChatInputBarConfiguration.IsFocused
	print(isFocused)
	
end)

(Btw, you can use 3 backticks, like this → ``` to make a code block - makes reading code much easier!)