Reference API Roblox

Engine API

Website

Related

Reference API Roblox

TextChannel

Represents a text chat channel.

Member index 6

HistoryMember
504AddUserAsync(userId: int64): Tuple
513DisplaySystemMessage(systemMessage: string, metadata: string = ): TextChatMessage
528SendAsync(message: string, metadata: string = ): TextChatMessage
514MessageReceived(incomingMessage: TextChatMessage)
514OnIncomingMessage(message: TextChatMessage): Tuple
549ShouldDeliverCallback(message: TextChatMessage, textSource: TextSource): Tuple
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553ClassName: string
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
553className: string
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
486GetChildren(): Objects
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
462GetPropertyChangedSignal(property: string): RBXScriptSignal
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsA(className: 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
553children(): Objects
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
553getChildren(): Objects
462isA(className: string): bool
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462Changed(property: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)

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.

To learn more, see In-Experience Text Chat.

History 13

Members 6

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]

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]

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