Skip to content

Service · inherits Instance

TextChatService

Official docs ↗

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

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 userId is not in the current server. Note that this method can be used with all current player UserIds in a Script with RunContext of RunContext.Server or RunContext.Legacy. This method can also be used in a LocalScript but only with the UserId of 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 (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.

  • 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 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.

    Note that this method is only available for use in a Script with RunContext of RunContext.Server or RunContext.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 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.

  • 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.CanUsersChatAsync pairwise 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

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 when TextChatService is 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.