Skip to content

Class · inherits Instance

TextChannel

Official docs ↗

Represents a text chat channel.

About TextChannel

Represents a text chat channel. Contains TextSources as descendants.

To send a chat message to the TextChannel, call TextChannel.SendAsync from a LocalScript. The corresponding TextSource of the user with TextSource.CanSend = true must be in that channel.

Messages from different TextChannels can be separated into different tabs in the chat window using ChannelTabsConfiguration. Multiple channels with the same name might cause unexpected behavior with the chat window, even if the player isn't a member of the other channels.

To learn more, see In-Experience Text Chat.

Properties 1

  • DirectChatRequester: PlayerReadOnlyNotReplicatedThe TextChannel will only deliver messages to users that can send direct messages to the DirectChatRequester.

    The TextChannel will only deliver messages to users that can send direct messages to the DirectChatRequester. This property can only be set using SetDirectChatRequester().

Methods 4

  • AddUserAsync(userId: User) → TupleYieldsAdds a TextSource to the TextChannel given userId of a Player.

    Adds a TextSource to the TextChannel given userId of the user (with Player.UserId). Can only be used in a Script.

    If a TextSource representing the user does not exist, this adds a TextSource.

    If a TextSource representing the user does exist, this returns the TextSource.

    If the user has chat off or isn't in the server, this returns a tuple nil, false.

  • DisplaySystemMessage(systemMessage: string, metadata: string) → TextChatMessageDisplays a system message to the user.

    Displays a system message to user. Can only be used in a LocalScript, or in a Script with RunContext of RunContext.Client. Messages are only visible to that user and aren't automatically filtered or localized.

  • SendAsync(message: string, metadata: string) → TextChatMessageYieldsSends a TextChatMessage to the server.

    Sends a TextChatMessage to the server. Can only be used in a LocalScript, or in a Script with RunContext of RunContext.Client. Please note that only messages typed and sent by the user will be delivered.

    The metadata argument has a limit of 200 characters. If this is called with a metadata argument that has more than 200 characters, the message will not be sent to other users. Instead, the sender will receive a TextChatMessage with the TextChatMessage.Metadata and TextChatMessage.Text properties set to empty strings.

  • SetDirectChatRequester(requester: Player) → ()Sets the DirectChatRequester for the TextChannel. The TextChannel will only deliver messages to users that can send direct messages to the DirectChatRequester.

    Sets the DirectChatRequester for the TextChannel. This method is only available for use in server scripts.

    Use this API if you are working with TextChatService and have a custom implementation of direct chat outside of the default text channels.

    When called on a TextChannel that is parented to TextChatService and has no existing TextSources, SetDirectChatRequester adds the requested users as a TextSource and set the DirectChatRequester property for the channel.

    When DirectChatRequester is set, only messages between users that can direct chat with the DirectChatRequester are delivered.

Events 1

Callbacks 2

  • OnIncomingMessage(message: TextChatMessage) → TupleCalled when TextChannel is receiving an incoming message.
  • ShouldDeliverCallback(message: TextChatMessage, textSource: TextSource) → TupleCalled for each client when TextChannel is receiving an incoming message to determine whether or not it should be delivered to that client.

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