Allow TextChatService to have non-player speakers

As a Roblox developer, it is too hard to migrate to the new TextChatService system because there are a number of critical features that my game requires that are not provided within the framework of the new system. My game utilizes non-player speakers to create a more immersive environment, such as announcements when a player is killed by another player, something they did themselves, the environment, an NPC, etc… The feature is currently only provided with the legacy LUA chat system.

My primary use case is that I have NPCs who generate chat messages within the game. An NPC kills a player and wants to send message about the kill to everyone on the server. In the legacy system, this was easy to do. But the new system does not allow for this. I have read that this feature was already planned for by using a negative UserId for the player when joining a channel.

If this issue is addressed, it will improve my development experience by allowing me to migrate over to the new TextChatService without significantly reworking my codebase.

11 Likes

Non-player TextSources is something we are aware is missing from TextChatService and this post is helpful in understanding this usecase.

I can offer a few workarounds that may enable some readers to emulate this behavior today.

Using a custom TextChannel for NPC dialog is a viable option here. Since we can emit messages from LocalScripts using TextChan el:DisplaySystemMessage, we can use this as a stand-in when receiving an incoming event.

We can use the second option argument of DisplaySytemMessage, the metadata arg, to annotate which NPC the message is coming from.

We can then use TextChannel.OnIncomingMessage to format the prefix text to read that it came from a particular NPC based on the metadata property of the incoming TextChatMessage.

All of this can be exposed through a simple interface similar to the previous chat system for compatibility if needed. If there is interest, I can provide an example to demonstrate.


Do continue to provide more support, ideas, and usecases for this feature request below.

3 Likes

I have thought about doing that, except there’s a problem with the documentation on that second parameter of TextChannel:DisplaySystemMessage(): There isn’t any. All it says is that it’s a string.

So what do we put in there? It is a freeform string whose format that we define or is there some specific keywords with parameters and separators like a web string (like this: SomeWebServerName/?param1=value1&param2=value2)? I also looked at the guides and there is nothing mentioned there either.

Another use case in my game is that I make some relatively creative player death messages that are broadcast to all players. Messages like “Player $s’s head was taken off by $s railgun slug.” or “Player $s stepped off into the void and wasn’t seen again.” for when they fall to their death from a platform. Another one is “Player $s stepped on $s’s grenade.” You get the idea. Basically, a player kills another player with a weapon, and it gets announced in chat with creative messages. I use non-player speakers for that as well.

Hopefully this gets added relatively quickly, but I do understand the software development cycle being a systems software engineer myself. I figure that development sprints are between 2-6 weeks with retrospect meetings after each sprint.

2 Likes

Good question, you can put any form of string there you want. It can be a simple string of the NPCs name or it could be something more nuanced like JSON or an example like you’ve suggested.

The field is reserved for the developer to use to offer hints or attach special decorators/metadata to a TextChatMessage. This can be read from an OnIncomingMessage callback. TextChatService internally doesn’t read or use this field meaningfully in any capacity.

Examples of existing messages with this Metadata field are the default system messages. All Roblox default system messages are emitted to the RBXSystem TextChannel with a metadata field assigned for each.

An example of one of these system messages is the friend joined system message event. This has a metadata property something like Roblox.Friend.Info.Joined. Or attempting to use an emote that doesn’t exist might have metadata string as Roblox.Emote.Error.DoesNotExist.

RBXSystem channel has an OnIncomingMessage callback to format metadata strings with Error in them in red and Info in grey.

Developers can also read these strings to disable these messages by replacing the body text with an empty whitespace character.

When we detect these events have occured, we call TextChannel:DisplaySytemMessage(message, metadata)

We use these metadata strings to know what color and formatting to apply to these system messages. Since they are not guaranteed to be the same message across different languages, we needed some standard identifier.

Yeah something like that every 2 weeks

4 Likes