TextChatService
A service handling in-experience text chat.
Memory category | Instances |
---|
Member index 22
Description
A service handling in-experience text chat, including managing channels, decorating messages, filtering text, creating commands, and developing custom chats interfaces.
To learn more, see TextChatService Overview.
For further customization, TextChatService has the following singleton children:
History 39
- 650 Add CanUsersDirectChatAsync
- 649 Add
- 646 Add CanUsersWhisperAsync
- 645 Add OnChatWindowAdded
- 599 Change Tags of from [] to [Hidden, NotReplicated]
- 599 Add
- 599 Change CanLoad of ChatTranslationEnabled from true to false
- 599 Change CanSave of ChatTranslationEnabled from true to false
- 599 Change Tags of ChatTranslationEnabled from [] to [NotReplicated]
- 595 Add
- 595 Add
- 595 Add ChatTranslationEnabled
- 587 Add OnBubbleAdded
- 587 Change Parameters of BubbleDisplayed from (part: Instance, message: string) to (partOrCharacter: Instance, textChatMessage: TextChatMessage)
- 580 Add BubbleDisplayed
- 580 Add DisplayBubble
- 580 Add CanUsersChatAsync
- 580 Add CanUserChatAsync
- 553 Add
- 553 Add
- 553 Add
- 553 Change Default of CreateDefaultTextChannels from to true
- 553 Change Default of CreateDefaultCommands from to true
- 553 Change Default of ChatVersion from to LegacyChatService
- 533 Change Tags of TextChatService from [NotCreatable, Service, NotBrowsable] to [NotCreatable, Service]
- 519 Change Security of SendingMessage from RobloxScriptSecurity to None
- 518 Change Security of SendingMessage from None to RobloxScriptSecurity
- 516 Change WriteSecurity of CreateDefaultTextChannels from None to PluginSecurity
- 516 Change Tags of CreateDefaultTextChannels from [NotScriptable] to []
- 516 Change WriteSecurity of CreateDefaultCommands from None to PluginSecurity
- 516 Change Tags of CreateDefaultCommands from [NotScriptable] to []
- 514 Add OnIncomingMessage
- 514 Add SendingMessage
- 514 Add MessageReceived
- 514 Add CreateDefaultTextChannels
- 514 Add CreateDefaultCommands
- 514 Add ChatVersion
- 514 Change Tags of TextChatService from [NotCreatable, Service, NotReplicated] to [NotCreatable, Service, NotBrowsable]
- 496 Add TextChatService
Members 22
BubbleDisplayed
Parameters (2) | |
---|---|
partOrCharacter | Instance |
textChatMessage | TextChatMessage |
Fires when TextChatService:DisplayBubble() is called.
Thread safety | Unsafe |
---|
History 2
- 587 Change Parameters of BubbleDisplayed from (part: Instance, message: string) to (partOrCharacter: Instance, textChatMessage: TextChatMessage)
- 580 Add BubbleDisplayed
CanUserChatAsync
Parameters (1) | ||
---|---|---|
userId | int64 | |
Returns (1) | ||
bool |
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 userId is not in the current server. Note that this method is only available for use in a Script with RunContext of RunContext.Server or RunContext.Legacy.
Thread safety | Unsafe |
---|
History 1
- 580 Add CanUserChatAsync
CanUsersChatAsync
Parameters (2) | ||
---|---|---|
userIdFrom | int64 | |
userIdTo | int64 | |
Returns (1) | ||
bool |
Determines whether or not two users would receive messages between each other. Factors such as incompatible parental control settings or blocked status may prevent the delivery of messages between users TextChannels internally use this result to determine whether to deliver messages between users. Note that this method is only available for use in a Script with RunContext of RunContext.Server or RunContext.Legacy.
Thread safety | Unsafe |
---|
History 1
- 580 Add CanUsersChatAsync
CanUsersDirectChatAsync
Parameters (2) | ||
---|---|---|
requesterUserId | int64 | |
userIds | Array | |
Returns (1) | ||
Array |
Determines whether a user has permission to chat directly with other users in experiences based on their parental control settings. To be used when:
- The line of communication is user-initiated (not developer- or gameplay-initiated)
- Access to the communication is closed and limited
An example of a direct chat is a whisper channel between two users.
You may use this method to gate certain features in your experience depending on the result.
When creating a TextChannel for a direct chat, use TextChannel:SetDirectChatRequester to set the requesterUserId so that the channel can determine whether to deliver messages between users. When TextChannel.DirectChatRequester is non-nil, TextChannels internally use this result to determine whether to deliver messages between users.
1 2 3 4 5 6 7 |
|
Note that this method is only available for use in a Script with RunContext of RunContext.Server or RunContext.Legacy.
Thread safety | Unsafe |
---|
History 1
CanUsersWhisperAsync
Parameters (2) | ||
---|---|---|
fromUserId | int64 | |
toUserId | int64 | |
Returns (1) | ||
bool |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 1
ChatTranslationEnabled
Type | Default | |
---|---|---|
bool | true |
Determines if chat translation is enabled. If true, a system message will notify player's when their first join that chat messages may be translated into the player's preferred language.
Write security | RobloxScriptSecurity |
---|---|
Thread safety | ReadSafe |
Category | Data |
Loaded/Saved | false |
History 4
- 599 Change CanLoad of ChatTranslationEnabled from true to false
- 599 Change CanSave of ChatTranslationEnabled from true to false
- 599 Change Tags of ChatTranslationEnabled from [] to [NotReplicated]
- 595 Add ChatTranslationEnabled
ChatVersion
Type | Default | |
---|---|---|
ChatVersion | LegacyChatService |
Determines whether to fully enable TextChatService or revert to the legacy chat system. Setting this property to ChatVersion.LegacyChatService effectively disables TextChatService.
Write security | NotAccessibleSecurity |
---|---|
Thread safety | ReadSafe |
Category | Data |
Loaded/Saved | true |
History 2
- 553 Change Default of ChatVersion from to LegacyChatService
- 514 Add ChatVersion
CreateDefaultCommands
Type | Default | |
---|---|---|
bool | true |
Determines whether TextChatService should create default TextChatCommands.
If true, the following TextChatCommands are created and put in a Folder named TextChatCommands inside TextChatService:
Name | Primary Alias | Secondary Alias | Description | Usage Example |
---|---|---|---|---|
RBXClearCommand | clear | cls | Clears the chat log for the local user. | /cls |
RBXConsoleCommand | console | Opens the Developer Console. | /console | |
RBXEmoteCommand | emote | e | Plays an avatar emote. | /e dance |
RBXHelpCommand | help | ? | Shows a list of chat commands. | /help |
RBXMuteCommand | mute | m | Mutes a user by their Name or DisplayName in all TextChannels. | /m Username |
RBXTeamCommand | team | t | Enters team chat mode where messages are only visible to teammates. | /t |
RBXUnmuteCommand | unmute | um | Unmutes a user by their Name or DisplayName in all TextChannels. | /um Username |
RBXVersionCommand | version | v | Shows the chat version. | /version |
RBXWhisperCommand | whisper | w | Enters whisper mode with another Player. | /w DisplayName or /w @Username |
Note that you can edit, create, and remove TextChatCommands even if CreateDefaultCommands is true. Also note that mute and unmute commands apply to all TextChannels.
Write security | PluginSecurity |
---|---|
Thread safety | ReadSafe |
Category | Data |
Loaded/Saved | true |
History 4
- 553 Change Default of CreateDefaultCommands from to true
- 516 Change WriteSecurity of CreateDefaultCommands from None to PluginSecurity
- 516 Change Tags of CreateDefaultCommands from [NotScriptable] to []
- 514 Add CreateDefaultCommands
CreateDefaultTextChannels
Type | Default | |
---|---|---|
bool | true |
Determines whether TextChatService should create default TextChannels. If true, a Folder named TextChannels is created inside TextChatService at runtime to contain the TextChannels outlined in the table below. Each of the default channels has the described special behavior applied to messages using its internally bound TextChannel.OnIncomingMessage callback function, changing how messages appear when sent through the channel. The callback is assigned automatically either at runtime (if the TextChannel exists) or when the TextChannel is created.
Channel | Description |
---|---|
RBXGeneral | TextChannel for player messages. In the chat window, messages are modified such that PrefixText receives a rich text font color tag to give chatting players their distinctive name color. If Player.Team exists, that Team.TeamColor is used instead of the default name color. |
RBXSystem | TextChannel for system messages. In the chat window, messages are modified such that TextChatMessage.Text is given a light grey color tag by default, or a red color tag if TextChatMessage.Metadata contains the word "Error" . |
RBXTeam[BrickColor] | TextChannel for team-specific player messages, created when a TeamColor is in use by any Team within the Teams service. Name of the created channel is RBXTeam followed by the TeamColor name. For example, RBXTeamCrimson is a TextChannel created when there is an active team whose TeamColor property is the "Crimson" BrickColor. In the chat window, messages are modified such that PrefixText is colored according to the TeamColor and is prepended with [Team]. Team channels create TextSources for all non‑Neutral players with the matching TeamColor, allowing them to use team‑only chat. Channels are removed if there are no remaining teams with an associated TeamColor. |
RBXWhisper:[UserId1]_[UserId2] | TextChannel for whisper messages between two players, created when a player uses the /whisper command on another player. For example RBXWhisper:2276836_505306092 is a TextChannel for players with UserIds 2276836 and 505306092. Inside whisper channels are two TextSources associated with the respective UserIds.In the chat window, messages are colored the same as those in RBXGeneral and TextChatMessage.PrefixText is modified to show whether a message was sent from or received by the local user. Whisper channels are removed when either player leaves the experience. |
Note that the default TextChannel.OnIncomingMessage callbacks can be overwritten. Also note that you can edit, create, and remove TextChannels even if CreateDefaultTextChannels is true.
Messages from different TextChannels can be separated into different tabs in the chat window using ChannelTabsConfiguration.
Write security | PluginSecurity |
---|---|
Thread safety | ReadSafe |
Category | Data |
Loaded/Saved | true |
History 4
- 553 Change Default of CreateDefaultTextChannels from to true
- 516 Change WriteSecurity of CreateDefaultTextChannels from None to PluginSecurity
- 516 Change Tags of CreateDefaultTextChannels from [NotScriptable] to []
- 514 Add CreateDefaultTextChannels
DisplayBubble
Parameters (2) | ||
---|---|---|
partOrCharacter | Instance | |
Returns (1) | ||
null |
Displays a chat bubble above the provided part or player character, and fires the BubbleDisplayed event 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 a Script with RunContext of RunContext.Client.
Thread safety | Unsafe |
---|
History 1
- 580 Add DisplayBubble
MessageReceived
Parameters (1) | |
---|---|
textChatMessage | TextChatMessage |
Like TextChannel.MessageReceived, fires when TextChannel:DisplaySystemMessage() is invoked on the client, or when the client receives a valid TextChannel:SendAsync() response from the server. This event is only fired on the client.
If the server's TextChannel.ShouldDeliverCallback property is
bound and returns false
, the client will not fire
TextChatService.MessageReceived.
Use the TextChatMessage parameter to get the TextSource and the text of the message (with TextChatMessage.Text).
The TextChatMessage parameter is the final result of any functions bound to TextChatService.OnIncomingMessage or TextChannel.OnIncomingMessage.
Thread safety | Unsafe |
---|
History 1
- 514 Add MessageReceived
OnBubbleAdded
Parameters (2) | ||
---|---|---|
adornee | Instance | |
Returns (1) | ||
Tuple |
Called when a bubble chat is about to be displayed. This can only be implemented on the client.
Use this to customize individual bubble chat messages. If this callback returns a BubbleChatMessageProperties, those properties will be applied to the associated bubble, overriding BubbleChatConfiguration properties. If a UICorner, UIGradient, or ImageLabel is parented under BubbleChatMessageProperties, they will also override their respective counterparts defined in BubbleChatConfiguration.
If the chat message is sent by a player, message.TextSource
will
correspond to that player, and adornee
will be nil
.
If the chat message is sent via TextChatService:DisplayBubble,
adornee
will be the partOrCharacter
provided, and message.TextSource
will be nil
.
Thread safety | Unsafe |
---|
History 1
- 587 Add OnBubbleAdded
OnChatWindowAdded
Parameters (1) | ||
---|---|---|
Returns (1) | ||
Tuple |
Called when a new message is about to be displayed in the chat window. This can only be implemented on the client.
Use this to customize individual messages that appear in the chat window. If this callback returns a ChatWindowMessageProperties, those properties will be applied to the associated message, overriding ChatWindowConfiguration properties. If a UIGradient is parented under ChatWindowMessageProperties, it will also override the TextColor3 property defined in ChatWindowConfiguration.
Thread safety | Unsafe |
---|
History 1
- 645 Add OnChatWindowAdded
OnIncomingMessage
Parameters (1) | ||
---|---|---|
Returns (1) | ||
Tuple |
Called when TextChatService is receiving an incoming message. Can only be implemented on the client.
Use this to decorate TextChatMessages. If this callback returns a TextChatMessageProperties, those properties are merged with the TextChatMessage parameter to create a new TextChatMessage.
When bound to the client sending a message, this callback is run twice; first when the message is initially sent and received locally, and again when the client receives the result of the filtered message from the server.
Note that this TextChatService.OnIncomingMessage callback runs before any TextChannel.OnIncomingMessage callbacks.
This should be defined only once in the source code. Multiple bindings will override one another in a non‑deterministic manner.
Thread safety | Unsafe |
---|
History 1
- 514 Add OnIncomingMessage
SendingMessage
Parameters (1) | |
---|---|
textChatMessage | TextChatMessage |
Fires when TextChannel:SendAsync() is called by the sending client. Use this to allow placeholder messages to be shown to the user while waiting for server response to TextChannel:SendAsync().
Thread safety | Unsafe |
---|
History 3
- 519 Change Security of SendingMessage from RobloxScriptSecurity to None
- 518 Change Security of SendingMessage from None to RobloxScriptSecurity
- 514 Add SendingMessage