View Old Messages In Chat When You Join (TextChatService)

If your experience uses TextChatService, you will notice that there is no chat history when you join. You only see new chats that are sent after you joined.

My perspective:

image

My friend’s perspective:

With the legacy chat (formerly known as “Lua Chat System”), it did store recent chat history, but it only displayed the chat messages from players currently in game. This resulted in awkward things like this:

Before:

After jack leaves, and I rejoin:

Jack is not in the game when I rejoin

A bit awkward with some of the messages missing, since anyone who joins would see those messages and think I’m talking to myself


I created a model that I call Chat History Log for experiences using TextChatService. It stores recent chat history so that joining players can read the conversation from before they joined. It also does not have the "missing chatters" problem that the legacy chat service had.

Chat History Log, my perspective:

image

Chat History Log, my friend’s perspective:

image

Names from the chat history log are displayed in the format DisplayName (@Username). This ensures you can know the identity of who was chatting, even if they have left the experience.

This is pretty rudimentary, so there’s no user-friendly settings interface or anything. If you can read the scripts, you can edit them to do what you want.

Get it here:

Just place the folder inside ReplicatedStorage and it will work.

Quick facts:

  • The message log is capped at 47 messages. When I tested it, TextChatService started hiding old messages once message #48 was reached.

  • Chat History Log supports names with Verified badges.

    • Apparently, Roblox relegates the Verified badge to this symbol:

      image

      I guess it’s a dinosaur? Not really sure what that means. I just copied and pasted it from the CoreGui element which had my check mark, and it worked. Trying to paste it here defaults to a placeholder unicode symbol , so if you want that bit of text, just open up the clientside script in the model.
  • This uses Player.Chatted to log chat messages. It does not use any TextChatService callbacks like OnIncomingMessage, so you don’t need to worry about those being overridden if you use them.

  • Whisper and emote messages (those beginning with /w and /e ) are not logged

    • There seems to be no way to detect team messages in order to prevent them from being logged
  • Chat History Log calls TextService:FilterStringAsync when a message is sent, and calls TextFilterResult:GetChatForUserAsync on all 47 chat log messages when a user joins

    • TextFilterResult:GetChatForUserAsync is not run in 1-by-1 order, but rather it’s run on all logged messages at the same time

      • This means they are all filtered at the same time, so the client does not need to wait for all messages to be filtered in a yielding chain
    • Messages which fail to load because the filter isn’t working are displayed with this message:

      image

      • Working filter:

        image

        • The filtered message was “My phone number is 8352” (not a real phone number)
  • The entire chat log is displayed as a single system message in the RBXGeneral TextChannel, with each individual chat message separated by line feed characters (\n)

  • TextChatService uses RichText, and it is used here to color the parts of the text with player names or “failed to filter” messages

  • Names from the pre-join chat log cannot be clicked or tapped to enter whisper mode

  • The logged chat messages successfully appearing in the chat window is a behavior that, unfortunately, relies upon a race condition being fulfilled (whether the chat window has loaded yet after the user has joined)


If you have any suggestions or have modified/improved the functionality in some way, feel free to post below!
39 Likes

Thank you GFink, very cool!
image

3 Likes

This is actually really good, I wonder why Roblox hasn’t done this themselves :thinking:

2 Likes

idk why but it wont load for me

Can you elaborate on what isn’t loading? Is the model not inserting into Studio or are the scripts not working when you test it?

I believe this would have issues with private chatting.

This is already addressed in the OP

It inserts in roblox but wont work when testing/in game, like it’s not there

How are you testing it? Admittedly this is not an easy thing to test, because you need to have someone else chat in game before you join so that you can see what they wrote after you join. Any errors in the console as well? Is TextChatService enabled?

This does not save chat logs with data stores or save logs from other servers if that’s what you were hoping.

so I’ve been using this for few months now, works great but recently I think it started picking up whisper messages in the logs when you join.

because I was just whispering with this player then I left the server & re-joined to see that. D:
image

just something to report