TextChatMessage is mutable

From the docs, TextChatMessage is an “immutable data object representing a text chat message”. Despite intending to be immutable, you’re able to write to the TextChatMessage’s properties without issue.

Example:

local textChatService = game:GetService('TextChatService')

function textChatService.OnIncomingMessage(textChatMessage)
	textChatMessage.Text = 'im not supposed to be able to write to this but i can'
end

results in:
image

Expected behavior

Either the TextChatMessage’s properties should be made read-only, or the docs should be updated to remove the word “immutable” from its description

11 Likes

This seems like a potential vulnerability if moderation done on text messages after OnIncomingMessages is allowed to modify it’s contents and while it can still be attributed to the player sending the message.

1 Like

i was able to filter messages that included toxic stuff with this feature

1 Like

And other people can do the complete opposite by making people say some things that can get people terminated. It’s best to just leave it up to the Roblox filter than to risk another DWC situation.

1 Like

This should be considered a typo in the docs. People could very easily just make their own chat system? I don’t see what the issue is here

Kinda weird how this still has not been fixed in almost 2 years, I pointed it out too: New In-Experience Text Chat System Public Release! - #79 by BackspaceRGB

It can’t get them terminated because the message gets sent to Roblox servers separately. By filtering I meant completely stopping the message from being sent, which happens when you set it to " ".

I highly doubt this. It’s very unlikely Roblox would’ve made such a huge security issue, and not only this, but it would’ve been abused by now if this was the case. I might do some testing to check this out.

1 Like

TextChatMessageProperties also allows developers to change displayed message contents (and that is intended). Also, the callback mentioned; OnIncomingMessage; is implemented only on the client and I could only hope that filtering is handled on the server.

2 Likes

Judging by overall API and connectivity to servers (and Studio behavior), filtering is definitely done on the server.

Thanks for the report! We’ll follow up when we have an update for you.

1 Like

You’re supposed to use TextChatService.OnIncomingMessage