This script uses the utilizes the new TextChatService to add prefixes (chat tags), name colors (classic or chosen), and chat colors (in the future). The customization allows for you to assign these to players, groups, gamepass owners, badge owners, team players, players with a tag, and players with an attribute.
Quick Note
This is a proof of concept and is not yet fully optimized. I just wanted to get it out as quickly as I could so that people could have a reference.
I am working on an improved version (also renamed) that will be easier to configure and will have a small optimization. Plus it will allow for future updates by switching to a variety handler system for incoming messages, dependent on if it’s a player, system message, and so on.
I will definitely include that in the next update!
Nevermind. I just realized I there is no gradient option for rich text and I can’t add a UIGradient object to the prefix text label because Roblox doesn’t expose that to developers
It does not, at this moment, no. I may add that in the future if Roblox intends to continue support for this new chat system (they have not made any updates in a while).
This is not just you. Unfortunately, Roblox shows the message before extra data has been calculated and added in order to make it “feel responsive” (their words) however that makes it look really ugly when applying prefixes and such. In the legacy Roblox chat, it applied everything BEFORE making the message visible. More information can be found in this post New Beta In-Experience Chat System for Channels, Filtering and More! - #155 by be_nj
Could you calculate the prefixes before the chat message is sent? Like when the player joins the game or a text channel? Yielding within OnIncomingMessage is supported but not ideal since it will delay the rendering of the message arbitrarily.
I could try that, yes. The only reason I didn’t is to recalculate if someone gets a badge, buys a gamepass, joins a group (although this is cached weirdly anyway on Roblox’s end).
The more optimal way would be to do it once and leave it, much like the legacy Roblox chat does with ExtraData.
I may do it for this reason + performance reasons (recalculating after every message is a bit ehh).
I believe do have a cache though that it won’t “recalculate” the game passes, badges, and group for 30 seconds at a time.
You could save your “ExtraData” as attributes on the TextSource or Player object. When the player connects you could write to asset ownership and group membership as attributes and update these attributes if needed during the game session.
Your OnIncomingMessage hooks would simply read from these attributes.
We recommend this because if this information is important enough to show before each chat message, it likely has some tangible gameplay implications as well, and confining that information in a chat&specific context would not let you easily reuse that information (it would have to be stored external if chat anyway)