TextChatService+

Always gotta site sources :wink:

You bet, that’s a nice source.

1 Like

Cool.
Few things:

  1. Does this not support multiple prefixes?
  2. For the client (only) there’s a 1s delay applying the actual colour and prefix to the message, is that just me?
1 Like
  1. 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).

  2. 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

1 Like

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.

1 Like

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.

1 Like

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)

I do like that. I may rewrite the script then for those performance optimizations. This version was written very hastily and didn’t really have much care put into it, to be honest.

1 Like

Update 1.2.0


Changes

  • Cached “ExtraData” when player joins, when team updates, when attribute updates, when they are added/removed from a CollectionService tag, or every 10 seconds (by default)
  • Minor optimizations for performance; messages now show very quickly.

I briefly looked over your github repository and noticed you have a different code path for Sending and Success messages:

Shouldnt your sending handler also read the attributes like the Success one? I think that may be the artifacting that you’re seeing.

1 Like

:person_facepalming:
You are, in fact, correct. The reason I separated sending and success is because I found it weird that it was happening in the first place. But I should just use the same function for both… :laughing:

1 Like

lol, no worries. happens to the best of us :smile:

7 Likes

Where do I place it in studio?

Is there a way to change the font depending on what group rank they are or if they have a gamepass?

Also, I found a bug while using this. Whenever a player joins it errors, the error is attempt to index nil with Group. Although the error doesn’t actually break anything it still isn’t nice for the developer console to be spammed. Not sure if it’s cause I set something up wrong of if it’s something wrong with the system.

Here’s an image of the full error:

how do i set this up idk how to do this!

Is there a reason the video is now private? Not really sure how to use this; as far as I can tell it’s a LocalScript with some modules underneath and no ready way for developers to interface with it.

Well, I suppose there’s this:

but at first glance I’m seeing no functions to interface with here in order to apply that data.

Setting the attribute on my own doesn’t appear to work either:

Server:

game.Players.PlayerAdded:Connect(function(player)
	player:SetAttribute("ChatData_PrefixText", "Owner")
end)

image

image
(attribute automatically replicates to the client)

Nevermind, there just needed to be a prefix color as well:

game.Players.PlayerAdded:Connect(function(player)
	player:SetAttribute("ChatData_PrefixText", "Owner")
	player:SetAttribute("ChatData_PrefixColor", "FF0000")
end)

image

I would suggest that if no prefix color is specified, have your script either use a default color or just error to inform the developer it’s required.

I’d also add that Roblox now allows you to remove the colon from the TextChatMessageProperties.PrefixText.

I understand if you do not intend to maintain this project, but otherwise I hope this helps. I am currently writing some literature about TextChatService functionality, and I’m working through modules like this to see how developers have been using it.

Thanks!

Aye, this is a very outdated module that is based on when the service was first released. I haven’t been able to maintain it due to restrictions with my job (a non-compete that applies to open source).

I have been wanting to re-make it in a more proper and up-to-date way, but I just haven’t been able to :frowning:

I went ahead and made the video unprivate (I made all the videos in my channel private and it affected that one).

Thank you, I will check the videos out. You may see I linked your thread here from a thread I spent the past day writing up.

How am I supposed to set priorities? I’m the owner but also own a gamepass, so on one player’s screen it displays the owner prefix while on my screen it displays gamepass prefix

Please update this, we really need it.