Hi everyone,
As part of our continued investment into TextChatService, we’re excited to announce new developer capabilities!
Chat Window Customization
To allow you to best customize the default chat window to fit your experience’s aesthetic and UI layout, we’ve introduced several new properties to the ChatWindowConfiguration instance, parented under TextChatService.
With these, you can now change the position and size of the chat window!
You can also change the appearance of the chat window!
Message Delivery APIs
We’ve introduced a new API, TextChannel:ShouldDeliverCallback
, which allows you to specify if a given message should be delivered to certain players. Here are some of the potential use cases that this supports:
-
Proximity-based chat where players can only communicate with those close to them.
-
Game where dead players’ messages will not be sent to living players.
-
Guessing game where correct guesses in chat will not be seen by other players.
Here’s an example of proximity-based chat!
To specify this behavior, you can supply the callback with a function that takes in the textChatMessage
and a target textSource
(the player it will be sent to). If this function returns false, the message will not be delivered. Here is a code sample for the demo above:
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local generalChannel : TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral
local function getPositionFromUserId(userId)
local targetPlayer = Players:GetPlayerByUserId(userId)
if targetPlayer then
local targetCharacter = targetPlayer.Character
if targetCharacter then
return targetCharacter:GetPivot().Position
end
end
-- return default position for example
return Vector3.new(0, 0, 0)
end
generalChannel.ShouldDeliverCallback = function(textChatMessage: TextChatMessage, targetTextSource: TextSource)
local sourcePos = getPositionFromUserId(textChatMessage.TextSource.UserId)
local targetPos = getPositionFromUserId(targetTextSource.UserId)
-- If the distance between players is less than 50, deliver the message.
return (targetPos - sourcePos).magnitude < 50
end
Note: This callback should be defined on the server. Additionally, this callback will not work properly if the function yields.
What’s next?
-
We will continue investing in developer customization needs for TextChatService, such as ChatInputBar configurations and more.
-
We will also soon be making TextChatService the default for new experiences.
What is TextChatService?
TextChatService is a safe, modern, and easily extendable chat that is a successor to the existing Chat service. This system is more sustainable for engineers at Roblox to iterate on, which means that we will be delivering regular fixes and new features to TextChatService that won’t conflict with any code you may have written that uses it.
How to switch to TextChatService
Please read this guide on how to enable TextChatService.
If you have any difficulties migrating your experience to TextChatService, please reach out to us! We have a support channel where the engineers on our team are willing to directly assist you. If you would like to be added, please send me a direct message!
Special thanks to @be_nj, @daweezy99, and @SubtleShuttle for their work on these capabilities!