Reference API Roblox

Engine API

Website

Related

Reference API Roblox

TextChatMessage

Immutable data object representing a text chat message.

This class is not creatable. Instances of this class cannot be created with Instance.new.
Tags: [NotCreatable]

Member index 12

HistoryMember
587BubbleChatMessageProperties: BubbleChatMessageProperties
644ChatWindowMessageProperties: ChatWindowMessageProperties
514MessageId: string
513Metadata: string
513PrefixText: string
513Status: TextChatMessageStatus
513Text: string
553TextChannel: TextChannel
553TextSource: TextSource
553Timestamp: DateTime
595Translation: string
inherited from Instance
553Archivable: bool
670Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
670Sandboxed: 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
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: 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()
657StyledPropertiesChanged()
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

Immutable data object representing a text chat message.

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

History 16

Members 12

BubbleChatMessageProperties

TypeDefault
BubbleChatMessageProperties

History 1

ChatWindowMessageProperties

TypeDefault
ChatWindowMessageProperties

History 1

MessageId

TypeDefault
string

A unique identifier for the TextChatMessage.

History 1

Metadata

TypeDefault
string

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.

local TextChatService = game:GetService("TextChatService")

local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral

generalChannel:DisplaySystemMessage("This is an error!", "Game.Error.Generic")
generalChannel:DisplaySystemMessage("Could not find save data!", "Game.Error.SaveDataNotFound")

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

generalChannel.OnIncomingMessage = function(message: TextChatMessage)
	if string.find(message.Metadata, "Error") then
		local overrideProperties = Instance.new("TextChatMessageProperties")
		overrideProperties.TextColor = Color3.fromRGB(255, 0, 0)
		return overrideProperties
	elseif string.find(message.Metadata, "Info") then
		local overrideProperties = Instance.new("TextChatMessageProperties")
		overrideProperties.TextColor = Color3.fromRGB(0, 255, 150)
		return overrideProperties
	end

	return nil
end

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

MetadataDescription
Roblox.ChatTranslation.ChatWindow.SystemMessageIndicates that the system may translate chat messages for the player.
Roblox.Notification.Friend.JoinedDisplayed when one of the player's friends join the experience.
Roblox.MessageStatus.Warning.FloodcheckedDisplayed when the player's sent message was rate limited by the server.
Roblox.MessageStatus.Warning.TextFilterFailedDisplayed when the player's sent message could not be displayed due to a text filtering issue.
Roblox.MessageStatus.Warning.InvalidPrivacySettingsDisplayed when the player's privacy settings prevent them from sending a message.
Roblox.MessageStatus.Warning.MessageTooLongDisplayed when the player sends a message with content that is too long.
Roblox.MessageStatus.Warning.UnknownDisplays when the system fails to send the player's message for an unknown reason.
Roblox.Help.InfoDisplays the response from the RBXHelpCommand TextChatCommand.
Roblox.Version.InfoDisplays the response from the RBXVersionCommand TextChatCommand.
Roblox.Team.Success.NowInTeamDisplayed when the player's team changes.
Roblox.Team.Error.CannotTeamChatIfNotInTeamDisplayed when the player triggers the RBXTeamCommand TextChatCommand without being on a Team.
Roblox.Whisper.Info.SuccessDisplayed when the player successfully starts a whisper conversation.
Roblox.Whisper.Welcome.SentDisplayed when entering a whisper TextChannel.
Roblox.Whisper.Error.CannotWhisperToSelfAn error response from the RBXWhisperCommand TextChatCommand.
Roblox.Whisper.Error.TargetDoesNotExistAn error response from the RBXWhisperCommand TextChatCommand.
Roblox.Whisper.Error.TooManyMatchesAn error response from the RBXWhisperCommand TextChatCommand.
Roblox.Whisper.Error.UnknownAn error response from the RBXWhisperCommand TextChatCommand.
Roblox.Emote.Error.DoesNotExistAn error response from the RBXEmoteCommand TextChatCommand.
Roblox.Emote.Error.UserEmotesNotEnabledAn error response from the RBXEmoteCommand TextChatCommand.
Roblox.Emote.Error.TemporarilyUnavailableAn error response from the RBXEmoteCommand TextChatCommand.
Roblox.Emote.Error.NotSupportedAn error response from the RBXEmoteCommand TextChatCommand.
Roblox.Emote.Error.SwitchToR15An error response from the RBXEmoteCommand TextChatCommand.
Roblox.Emote.Error.AnimationPlayingAn error response from the RBXEmoteCommand TextChatCommand.
Roblox.Mute.Error.PlayerNotFoundAn error response from the RBXMuteCommand TextChatCommand.
Roblox.Mute.Error.MultipleMatchesAn error response from the RBXMuteCommand TextChatCommand.
Roblox.Mute.Error.CannotMuteSelfAn error response from the RBXMuteCommand TextChatCommand.
Roblox.Mute.Info.SuccessAn success response from the RBXMuteCommand TextChatCommand.
Roblox.Unmute.Error.PlayerNotFoundAn error response from the RBXUnmuteCommand TextChatCommand.
Roblox.Unmute.Error.MultipleMatchesAn error response from the RBXUnmuteCommand TextChatCommand.
Roblox.Unmute.Error.CannotMuteSelfAn error response from the RBXUnmuteCommand TextChatCommand.
Roblox.Unmute.Info.SuccessAn success response from the RBXUnmuteCommand TextChatCommand.

History 1

PrefixText

TypeDefault
string

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.

History 1

Status

TypeDefault
TextChatMessageStatus

Indicates the status of the TextChatMessage.

History 1

Text

TypeDefault
string

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.

History 1

TextChannel

TypeDefault
TextChannel

A reference to the origin TextChannel.

History 2

TextSource

TypeDefault
TextSource

A reference to the origin TextSource.

History 2

Timestamp

TypeDefault
DateTime

A timestamp of when the message was originally sent.

History 2

Translation

TypeDefault
string

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.

History 1

Settings