Class · inherits Instance
TextChannel
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
: PlayerReadOnlyNotReplicatedTheTextChannelwill only deliver messages to users that can send direct messages to theDirectChatRequester.The
TextChannelwill only deliver messages to users that can send direct messages to theDirectChatRequester. This property can only be set usingSetDirectChatRequester().
Methods 4
AddUserAsync
(userId: User) → TupleYieldsAdds aTextSourceto theTextChannelgiven userId of aPlayer.Adds a
TextSourceto theTextChannelgiven userId of the user (withPlayer.UserId). Can only be used in aScript.If a
TextSourcerepresenting the user does not exist, this adds aTextSource.If a
TextSourcerepresenting the user does exist, this returns theTextSource.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 aScriptwithRunContextofRunContext.Client. Messages are only visible to that user and aren't automatically filtered or localized.SendAsync
(message: string, metadata: string) → TextChatMessageYieldsSends aTextChatMessageto the server.Sends a
TextChatMessageto the server. Can only be used in aLocalScript, or in aScriptwithRunContextofRunContext.Client. Please note that only messages typed and sent by the user will be delivered.The
metadataargument has a limit of 200 characters. If this is called with ametadataargument that has more than 200 characters, the message will not be sent to other users. Instead, the sender will receive aTextChatMessagewith theTextChatMessage.MetadataandTextChatMessage.Textproperties set to empty strings.SetDirectChatRequester
(requester: Player) → ()Sets theDirectChatRequesterfor theTextChannel. TheTextChannelwill only deliver messages to users that can send direct messages to theDirectChatRequester.Sets the
DirectChatRequesterfor theTextChannel. This method is only available for use in server scripts.Use this API if you are working with
TextChatServiceand have a custom implementation of direct chat outside of the default text channels.When called on a
TextChannelthat is parented toTextChatServiceand has no existingTextSources,SetDirectChatRequesteradds the requested users as aTextSourceand set theDirectChatRequesterproperty for the channel.When
DirectChatRequesteris set, only messages between users that can direct chat with theDirectChatRequesterare delivered.
Events 1
MessageReceived
TextChannel.MessageReceived:Connect(function(incomingMessage))Fires whenTextChannel.DisplaySystemMessageis invoked on the client, or when the client receives a validTextChannel.SendAsyncresponse from the server.Like
TextChatService.MessageReceived, fires whenTextChannel.DisplaySystemMessageis invoked on the client, or when the client receives a validTextChannel.SendAsyncresponse from the server. This event is only fired on the client.If the server's
TextChannel.ShouldDeliverCallbackproperty is bound and returnsfalse, the client will not fireTextChannel.MessageReceived.Use the
TextChatMessageparameter to get theTextSourceand the text of the message (withTextChatMessage.Text).The
TextChatMessageparameter is the final result of any functions bound toTextChatService.OnIncomingMessageorTextChannel.OnIncomingMessage.
Callbacks 2
OnIncomingMessage
(message: TextChatMessage) → TupleCalled whenTextChannelis receiving an incoming message.ShouldDeliverCallback
(message: TextChatMessage, textSource: TextSource) → TupleCalled for each client whenTextChannelis 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.