Reference API Roblox

Engine API

Website

Related

Reference API Roblox

TextChannel

Represents a text chat channel.

Member index 8

HistoryMember
651DirectChatRequester: Player
504AddUserAsync(userId: int64): Tuple
513DisplaySystemMessage(systemMessage: string, metadata: string = ): TextChatMessage
528SendAsync(message: string, metadata: string = ): TextChatMessage
651SetDirectChatRequester(requester: Player): null
514MessageReceived(incomingMessage: TextChatMessage)
514OnIncomingMessage(message: TextChatMessage): Tuple
549ShouldDeliverCallback(message: TextChatMessage, textSource: TextSource): Tuple
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Description

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.

To learn more, see In-Experience Text Chat.

History 15

Members 8

AddUserAsync

Parameters (1)
userIdint64
Returns (1)
Tuple

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.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

DirectChatRequester

TypeDefault
Player

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

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 1

Tags: [ReadOnly, NotReplicated]

DisplaySystemMessage

Parameters (2)Default
systemMessagestring
Returns (1)
TextChatMessage

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.

History 2

MessageReceived

Parameters (1)
incomingMessageTextChatMessage

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

History 3

OnIncomingMessage

Parameters (1)
messageTextChatMessage
Returns (1)
Tuple

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

TextChannel.OnIncomingMessage callbacks always run after the TextChatService.OnIncomingMessage callback.

This should be defined only once per TextChannel in the source code. Multiple bindings to the same channel will override one another in a nondeterministic manner.

When TextChatService:CreateDefaultTextChannels() is true, those default TextChannels have their TextChannel.OnIncomingMessage callbacks assigned internally in order to exhibit special default behavior.

History 1

SendAsync

Parameters (2)Default
messagestring
Returns (1)
TextChatMessage

Sends a TextChatMessage to the server. Can only be used in a LocalScript, or in a Script with RunContext of RunContext.Client.

This function yields. It will block the calling thread until completion.

History 2

Tags: [Yields]

SetDirectChatRequester

Parameters (1)
requesterPlayer
Returns (1)
null

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.

1
2
3
4
5
6
7
local function createWhisperChannel(fromPlayer, toPlayer)
  local whisperChannel = Instance.new("TextChannel")
  whisperChannel:SetDirectChatRequester(fromPlayer)
  whisperChannel:AddUserAsync(toPlayer.UserId)
  -- The TextChannel instance now has two TextSource instances.
  return whisperChannel
end

History 1

ShouldDeliverCallback

Parameters (2)
messageTextChatMessage
textSourceTextSource
Returns (1)
Tuple

Called for each client when TextChannel is receiving an incoming message to determine whether or not it should be delivered to that client. Can only be defined on the server.

Once defined, this callback needs to return a truthy value such as true, 1, or "hello" to deliver the message to said client. If the callback returns anything else (including nil), the message won't be delivered to that client, although the sender will see the message regardless.

The sender can be referenced by TextChatMessage.TextSource.

History 1

Settings