Difference between OnIncomingMessage and OnChatWindowAdded?

I cannot seem to find any sort of difference between these 2.

The Text chat overview Documentation uses OnChatWindowAdded to customize the message while this Assign chat tags Documentation uses OnIncomingMessage.

The documentation for OnChatWindowAdded and OnIncomingMessage Have very similar wording. They are both fired before a message is displayed, They both have a TextChatMessage Parameter, and they are both used to customize messages.

I’m not sure if it’s the wording throwing me off or what but this whole thing feels so confusing and unexplained to me.

Also Why do we need to change the prefix text on :DeriveNewMessageProperties() then return it at the end, instead of just changing the prefix text on the message itself? In my tests, they both worked the exact same. and Why do we have to use Instance.new("BubbleChatMessageProperties") When customizing Bubble chats but not Instance.new("TextChatMessageProperties") When customzing Chat messages that show up in the window?

1 Like

OnChatWindowAdded calls when a new message is about to be displayed in the chat window
OnIncomingMessage called when TextChatService is receiving an incoming message.

Difference?

OnIncomingMessage allows you to edit the incoming message (a.k.a a message that a player sent)
OnChatWindowAdded allows you to edit individual messages that appear in the chat window.

What to use?

Personally, I’d use OnIncomingMessage since there’s no reason for me to edit individual messages appearing in the chat window.

Because OnChatWindowAdded requires you to return a ChatWindowMessageProperties.
DeriveNewMessageProperties creates a new ChatWindowMessageProperties that is intended to be used during custom OnChatWindowAdded callbacks.

BubbleChatMessageProperties is only used for editing Bubble Chats.
TextChatMessageProperties is only used for editing text chats in the chat window.

So I guess when using :DisplaySystemMessage() Is that something that OnChatWindowAdded will pick up but something that OnIncomingMessage won’t? What I tested, they both picked it up.

I feel like they can both edit individual messages since they can both be called on the client, unless I’m not understanding individual messages. It’s been a couple years since I’ve seriously been in studio though so I might just need to be okay not understanding it until later.

No, them both will pick it up.

:DisplaySystemMessage() when called, OnIncomingMessage event will get fired because a message is being sent. Then OnChatWindowAdded event gets fired because a message is displayed in the chat window.

So, OnIncomingMessage fires before OnChatWindowAdded.