TextChatMessage's property 'TextSource' is sometimes nil

In our game Legends of the Aether: Amnisica we are experiencing issues with TextChatService.

The TextChatService API includes TextChatMessages which include a TextSource property, which includes the message sender’s UserId. Today in our game, players are unable to see eachothers messages due to a bug where this TextSource property is null on all incoming messages.

In our game’s code, we have the following excerpt used to alter the in-game chat to display Usernames instead of Display names:
image
In this code, we rely on the TextSource property to never be nil - Because why would it? However in-game, we are witnessing the following error when any player tries to send a message:


See line 5926 for matchup in both images.

This error log clearly states that the TextSource property is nil, which it should never be. This is a game-breaking bug that could impact a vast amount of developers games.

Issue seems to have resolved itself in live servers. Still a problem that TextSource could ever be nil in a TextChatMessage.

This is an issue with your code; there was an outage and you do not check TextChatMessage.Status in your code.
When the status is anything other than Success or Sending, you should probably assume the TextSource is nil. During the outage, we experienced no errors and properly displayed an error to the user in chat that the filter was experiencing issues.

However, the wiki documents TextSource to always be a string or empty string. It should probably be clarified to be optional.

1 Like

TextSource will be nil when the “system” sends a message so you should be designing your code around the fact that TextSource can be nil. “Friend joined notifications”, “Team change notifications” as well as any other Roblox-made or developer-made chat message will return no TextSource property in the TextChatMessage. This obviously doesn’t excuse the fact that normal messages are causing issues but still should something to be taken into account given your code setup.