Service · inherits Instance
TextChatService
A service handling in-experience text chat.
About TextChatService
A service handling in-experience text chat, including managing
TextChannels, decorating messages, filtering text,
creating TextChatCommands, and
developing custom chats interfaces.
To learn more, see
text chat overview.
For further customization, TextChatService has the following singleton
children:
Properties 3
ChatTranslationEnabled
: booleanNotReplicatedDetermines whether a user has chat translation enabled.Determines whether a user has chat translation enabled. If
true, messages the user receives will be translated into their preferred language. UseTextChatMessage.Translationto get the message translation. This property is client-side only and reflects the user's own preference; read it from aLocalScriptto adapt custom chat UIs when the user toggles translation.CreateDefaultCommands
: booleanDetermines whetherTextChatServiceshould create defaultTextChatCommands.Determines whether
TextChatServiceshould create defaultTextChatCommands. Iftrue, the followingTextChatCommandsare created and put in aFoldernamed TextChatCommands insideTextChatService:Note that you can edit, create, and remove
TextChatCommandseven ifCreateDefaultCommandsistrue. Also note that mute and unmute commands apply to allTextChannels.CreateDefaultTextChannels
: booleanDetermines whetherTextChatServiceshould create defaultTextChannels.Determines whether
TextChatServiceshould create defaultTextChannels. Iftrue, aFoldernamed TextChannels is created insideTextChatServiceat runtime to contain theTextChannelsoutlined in the table below. Each of the default channels has the described special behavior applied to messages using its internally boundTextChannel.OnIncomingMessagecallback function, changing how messages appear when sent through the channel. The callback is assigned automatically either at runtime (if theTextChannelexists) or when theTextChannelis created.Note that the default
TextChannel.OnIncomingMessagecallbacks can be overwritten. Also note that you can edit, create, and removeTextChannelseven ifCreateDefaultTextChannelsistrue.Messages from different TextChannels can be separated into different tabs in the chat window using
ChannelTabsConfiguration.
Methods 5
CanUserChatAsync
(userId: User) → booleanYieldsDetermines whether a user has permission to chat in experiences.Determines whether a user has permission to chat in experiences. Factors such as parental control settings may prevent the user from sending messages. Errors if the
userIdis not in the current server. Note that this method can be used with all current playerUserIdsin aScriptwithRunContextofRunContext.ServerorRunContext.Legacy. This method can also be used in aLocalScriptbut only with theUserIdof the local player.CanUsersChatAsync
(userIdFrom: User, userIdTo: User) → booleanYieldsDetermines whether or not two users can receive messages from each other.Determines whether or not two users can receive messages from each other. Both users must be in the current server, otherwise an error will occur.
Factors such as incompatible parental control settings or blocked status may prevent the delivery of messages between users (
TextChannelsinternally use this result to determine whether to deliver messages between users). Note that this method is only available for use in aScriptwithRunContextofRunContext.ServerorRunContext.Legacy.CanUsersDirectChatAsync
(requesterUserId: User, userIds: Array) → ArrayYieldsDetermines whether a user has permission to chat directly with other users in experiences based on factors such as their parental control settings.Determines whether a user has permission to chat directly with other users in experiences based on their parental control settings, such as a whisper channel between two users. To be used when:
- The line of communication is user-initiated (not developer- or gameplay-initiated).
- Access to the communication is closed and limited.
You may use this method to gate certain features in your experience depending on the result.
When creating a
TextChannelfor a direct chat, useTextChannel.SetDirectChatRequesterto set therequesterUserIdso that the channel can determine whether to deliver messages between users. WhenTextChannel.DirectChatRequesteris non-nil,TextChannelsinternally use this result to determine whether to deliver messages between users.Note that this method is only available for use in a
ScriptwithRunContextofRunContext.ServerorRunContext.Legacy.DisplayBubble
(partOrCharacter: Instance, message: string) → ()Displays a chat bubble above the provided part or player character.Displays a chat bubble above the provided part or player character, and fires the
BubbleDisplayedevent with the parameters specified in this method. Can display bubbles for non-player characters (NPCs) if you specify a part within the character, such as its head.Note that this method is only available for use in
LocalScript, or in aScriptwithRunContextofRunContext.Client.GetChatGroupsAsync
(players: Instances) → ArrayYieldsReturns chat group IDs that indicate which players can synchronously text chat together.Returns a sorted array of arrays of chat group IDs for the given players. Each chat group ID is a string that represents a communication-compatible group within the current universe.
If two or more players share the same chat group ID, those players are able to synchronously text chat with each other based on their age-check status and chat settings.
This method is server-side only and intended for real-time use cases such as matchmaking and teleporting. It is more efficient than calling
TextChatService.CanUsersChatAsyncpairwise when evaluating many players at once, since pairwise checks scale as N^2 and cannot be merged across player lists. Chat group IDs are unique to the current universe, may change over time, and should not be stored once the user has left the experience. While you can hold onto the data returned for the purposes of gameplay while the user is in the experience, this data should not be stored after they've left.To use this method, you must enable Chat & Voice Groups APIs in Experience Settings ⟩ Communication in Roblox Studio and agree to the Roblox Terms of Use.
In Roblox Studio this API is only available when the experience is running in Team Test.
Events 3
BubbleDisplayed
TextChatService.BubbleDisplayed:Connect(function(partOrCharacter, textChatMessage))Fires whenTextChatService.DisplayBubbleis called.MessageReceived
TextChatService.MessageReceived:Connect(function(textChatMessage))Fires whenTextChannel.DisplaySystemMessageis invoked on the client, or when the client receives a validTextChannel.SendAsyncresponse from the server.Like
TextChannel.MessageReceived, fires whenTextChannel.DisplaySystemMessageis invoked on the client, or when the client receives a validTextChannel.SendAsyncresponse from the server. This event is only fired on the client.If the server's
TextChannel.ShouldDeliverCallbackproperty is bound and returnsfalse, the client will not fireTextChatService.MessageReceived.Use the
TextChatMessageparameter to get theTextSourceand the text of the message (withTextChatMessage.Text).The
TextChatMessageparameter is the final result of any functions bound toTextChatService.OnIncomingMessageorTextChannel.OnIncomingMessage.SendingMessage
TextChatService.SendingMessage:Connect(function(textChatMessage))Fires whenTextChannel.SendAsyncis called by the sending client.Fires when
TextChannel.SendAsyncis called by the sending client. Use this to allow placeholder messages to be shown to the user while waiting for server response toTextChannel.SendAsync.
Callbacks 3
OnBubbleAdded
(message: TextChatMessage, adornee: Instance) → TupleCalled when a bubble chat is about to be displayed.OnChatWindowAdded
(message: TextChatMessage) → TupleCalled when a new message is about to be displayed in the chat window. This can only be implemented on the client.OnIncomingMessage
(message: TextChatMessage) → TupleCalled whenTextChatServiceis receiving an incoming message.
TextChatService also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.