Roblox UtilitiesDevlHub Roblox Documentation

Class

TextChatMessage

NotCreatable
Inherits
Instance › Object
Memory category
Instances

A data object representing a text chat message.

A data object representing a text chat message.

To learn more about using TextChatMessages, see In-Experience Text Chat.

Properties 11#

BubbleChatMessagePropertiesBubbleChatMessagePropertiesA reference to the BubbleChatMessageProperties that overrides the appearance of this message's chat bubble.ReadSafe
ChatWindowMessagePropertiesChatWindowMessagePropertiesA reference to the ChatWindowMessageProperties that overrides the appearance of this message in the chat window.ReadSafe
MessageIdstringA unique identifier for the TextChatMessage.ReadSafe
MetadatastringA general purpose field for storing miscellaneous data about the TextChatMessage.ReadSafe
PrefixTextstringA prefix to add to a user's message.ReadSafe
StatusTextChatMessageStatusIndicates the status of the TextChatMessage.ReadSafe
TextstringThe filtered text message for the user.ReadSafe
TextChannelTextChannelA reference to the origin TextChannel.ReadSafe
TextSourceTextSourceA reference to the origin TextSource.ReadSafe
TimestampDateTimeA timestamp of when the message was originally sent.ReadSafe
TranslationstringTranslated and filtered text message.ReadSafe

BubbleChatMessageProperties: BubbleChatMessageProperties#

ReadSafe

A reference to the BubbleChatMessageProperties instance that overrides BubbleChatConfiguration properties for this individual message's chat bubble.

This property is nil by default. It is populated when your TextChatService.OnBubbleAdded callback returns a BubbleChatMessageProperties instance: the returned instance is stored here on the resulting TextChatMessage. Any properties set on it take precedence over the shared BubbleChatConfiguration when the message's bubble is rendered.

ChatWindowMessageProperties: ChatWindowMessageProperties#

ReadSafe

A reference to the ChatWindowMessageProperties instance that overrides ChatWindowConfiguration properties for this individual message as displayed in the chat window.

This property is nil by default. It is populated when your TextChatService.OnChatWindowAdded callback returns a ChatWindowMessageProperties instance, typically created with ChatWindowConfiguration:DeriveNewMessageProperties(): the returned instance is stored here on the resulting TextChatMessage. Any properties set on it take precedence over the shared ChatWindowConfiguration when the message is rendered.

MessageId: string#

ReadSafe

A unique identifier for the TextChatMessage.

Metadata: string#

ReadSafe

A general purpose field for storing miscellaneous data about the TextChatMessage. The second argument of TextChannel:SendAsync() and TextChannel:DisplaySystemMessage() is used to populate this field.

Use this field to apply additional formatting for special messages within TextChatService.OnIncomingMessage and TextChannel.OnIncomingMessage callbacks.

Luau
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")

local customChannel: TextChannel = Instance.new("TextChannel")
customChannel.Parent = TextChatService:WaitForChild("TextChannels")

customChannel.OnIncomingMessage = function(message: TextChatMessage)
  if string.find(message.Metadata, "Error") then
    local overrideProperties = Instance.new("TextChatMessageProperties")
    overrideProperties.Text = string.format("<font color='rgb(255,0,0)'>%s</font>", message.Text)
    return overrideProperties
  elseif string.find(message.Metadata, "Info") then
    local overrideProperties = Instance.new("TextChatMessageProperties")
    overrideProperties.Text = string.format("<font color='rgb(0, 255, 150)'>%s</font>", message.Text)
    return overrideProperties
  end

  return nil
end

Players.LocalPlayer.CharacterAdded:Connect(function()
  customChannel:DisplaySystemMessage("This is an error!", "Game.Error.Generic")
  customChannel:DisplaySystemMessage("Could not find save data!", "Game.Error.SaveDataNotFound")

  customChannel:DisplaySystemMessage("You won the game!", "Game.Info.Win")
  customChannel:DisplaySystemMessage("You lost the game!", "Game.Info.Lose")
end)

As follows is a reference of the default system messages emitted by the chat system:

Metadata Description
Roblox.ChatTranslation.ChatWindow.SystemMessage Indicates that the system may translate chat messages for the player.
Roblox.Notification.Friend.Joined Displayed when one of the player's friends join the experience.
Roblox.MessageStatus.Warning.Floodchecked Displayed when the player's sent message was rate limited by the server.
Roblox.MessageStatus.Warning.TextFilterFailed Displayed when the player's sent message could not be displayed due to a text filtering issue.
Roblox.MessageStatus.Warning.InvalidPrivacySettings Displayed when the player's privacy settings prevent them from sending a message.
Roblox.MessageStatus.Warning.MessageTooLong Displayed when the player sends a message with content that is too long.
Roblox.MessageStatus.Warning.Unknown Displays when the system fails to send the player's message for an unknown reason.
Roblox.Help.Info Displays the response from the RBXHelpCommand Class.TextChatCommand.
Roblox.Version.Info Displays the response from the RBXVersionCommand Class.TextChatCommand.
Roblox.Team.Success.NowInTeam Displayed when the player's team changes.
Roblox.Team.Error.CannotTeamChatIfNotInTeam Displayed when the player triggers the RBXTeamCommand Class.TextChatCommand without being on a Class.Team.
Roblox.Whisper.Info.Success Displayed when the player successfully starts a whisper conversation.
Roblox.Whisper.Welcome.Sent Displayed when entering a whisper Class.TextChannel.
Roblox.Whisper.Error.CannotWhisperToSelf An error response from the RBXWhisperCommand Class.TextChatCommand.
Roblox.Whisper.Error.TargetDoesNotExist An error response from the RBXWhisperCommand Class.TextChatCommand.
Roblox.Whisper.Error.TooManyMatches An error response from the RBXWhisperCommand Class.TextChatCommand.
Roblox.Whisper.Error.Unknown An error response from the RBXWhisperCommand Class.TextChatCommand.
Roblox.Emote.Error.DoesNotExist An error response from the RBXEmoteCommand Class.TextChatCommand.
Roblox.Emote.Error.UserEmotesNotEnabled An error response from the RBXEmoteCommand Class.TextChatCommand.
Roblox.Emote.Error.TemporarilyUnavailable An error response from the RBXEmoteCommand Class.TextChatCommand.
Roblox.Emote.Error.NotSupported An error response from the RBXEmoteCommand Class.TextChatCommand.
Roblox.Emote.Error.SwitchToR15 An error response from the RBXEmoteCommand Class.TextChatCommand.
Roblox.Emote.Error.AnimationPlaying An error response from the RBXEmoteCommand Class.TextChatCommand.
Roblox.Mute.Error.PlayerNotFound An error response from the RBXMuteCommand Class.TextChatCommand.
Roblox.Mute.Error.MultipleMatches An error response from the RBXMuteCommand Class.TextChatCommand.
Roblox.Mute.Error.CannotMuteSelf An error response from the RBXMuteCommand Class.TextChatCommand.
Roblox.Mute.Info.Success An success response from the RBXMuteCommand Class.TextChatCommand.
Roblox.Unmute.Error.PlayerNotFound An error response from the RBXUnmuteCommand Class.TextChatCommand.
Roblox.Unmute.Error.MultipleMatches An error response from the RBXUnmuteCommand Class.TextChatCommand.
Roblox.Unmute.Error.CannotMuteSelf An error response from the RBXUnmuteCommand Class.TextChatCommand.
Roblox.Unmute.Info.Success An success response from the RBXUnmuteCommand Class.TextChatCommand.

PrefixText: string#

ReadSafe

A prefix to add to a user's message. This supports Rich Text, so developers can set custom properties for this text to support chat tags.

By default, TextChatMessage.PrefixText is the name of the TextSource, which is the Player.DisplayName of the user associated with the TextSource via TextSource.UserId.

Status: TextChatMessageStatus#

ReadSafe

Indicates the status of the TextChatMessage.

Text: string#

ReadSafe

The filtered text message for the user. Different users may receive different strings from this property based on filtering rules. It can be an empty string.

TextChannel: TextChannel#

ReadSafe

A reference to the origin TextChannel.

TextSource: TextSource#

ReadSafe

A reference to the origin TextSource.

Timestamp: DateTime#

ReadSafe

A timestamp of when the message was originally sent.

Translation: string#

ReadSafe

Represents translated and filtered text messages based on users' localization settings. The system doesn't translate messages between users with the same localization settings or using languages without the text filter support, so this property can be an empty string if no translation happens. For customization, see Customizing Translated Messages.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed