:DisplaySystemMessages() insert messages into text chat randomly instead of at the bottom

When using TextChannel:DisplaySystemMessage() (DSM), the message rarely starts inserting them at the wrong places.
This is the code I am using:

local displaymessage = remotes.UI.DisplayMessage

-- happens with both RBXGeneral and RBXSystem
local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXSystem 

displaymessage.OnClientEvent:Connect(function(message)
	generalChannel:DisplaySystemMessage(message)
end)

After a certain period of time (seems to be linked to amount of messages sent), DSM starts putting the messages BEFORE other chat messages that were already in the chat window.
Other notes: The normal chat window messages go through TextChatService.OnChatWindowAdded() in order to apply colored text, however the issue of chronological order only happens with DSM after many text messages are sent.

This happens both in studio and in game.

The text messages should be sent at the bottom of the window like this:

But after a while, they are inserted randomly in the window:

REPRO FILE:
Click the “send server message” button to see how the message is supposed to look like.
Clicking the “instant max text” button instantly sends 48 messages using DisplaySystemMessage, which is around the amount of messages i’ve tested for the bug to happen.
Then, click the “send server message” button to display multiple different lines, and they should be in the wrong positions.
textchatservice bug repro.rbxl (73.6 KB)

4 Likes

yeah i also noticed that sometimes, TextChatService messages (system or not) will just not appear in the chat window at all (i couldnt report it since i didnt know how to prove it)

but this may be a may better explanation of whats happening instead of the messages just not appearing lol

1 Like

Any update on this? It’s been a month and it doesn’t seem to be fixed yet. I found another issue as well, and that’s if you use the method to color nametags and use /whisper, the [From: player] no longer appears.

I recently started having a similar issue recently, although for me the messages start grouping together.

Normal behavior:

After using :DsplaySystemMessage() a lot:
(It never gets fixed. The adding order breaks permanently no matter how slowly the messages are sent).

1 Like

I looked into CoreGui.

Normally LayoutOrder of the chat entries is properly counted, but after rapid use, multiple messages start sharing the same LayoutOrder property which breaks the layout.

Here are some entries that all have 49 as the layout order.

1 Like

it does seem to be related to sending multiple messages at the same time. i tested using a simple queue and task.wait() delay, which seemingly fixed the layout order even after multiple 48-line messages. i’ll use this method for now, hopefully it still works a week from now lol

I also tried that but it doesn’t work for me.

might be a slightly different issue since i’m using displaysystemmessage, but heres my code if you want to verify:


local TextChatService =  game:GetService("TextChatService")
local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral

local messagecache = {}

displaymessage.OnClientEvent:Connect(function(message, messagetype)
	if not messagetype then
		local t = tick()
		table.insert(messagecache, t)
		while messagecache[1] ~= t do
			task.wait()
		end
		task.wait()
		generalChannel:DisplaySystemMessage(message)

		table.remove(messagecache, 1)
	end
end)

displaymessage is the remote event from the server

I’m also using :DisplayChatMessage(), I just messed up in my post.
My code works pretty much the same as yours.

I’m not sure if this is a long term fix, but I fixed it by putting the messages in a queue and then releasing them as a single message every 0.1s.

Here’s my code:

local msgQueue = {}

s2c:WaitForChild("msg").OnClientEvent:Connect(function(msg: string)
   table.insert(msgQueue, msg)
end)

task.spawn(function()
	local channel: TextChannel = TCS:WaitForChild("TextChannels"):WaitForChild("RBXGeneral")
	
	while wait(0.1) do
		local queue = msgQueue
		
		if #queue == 0 then
			continue
		end

		msgQueue = {}
		
		channel:DisplaySystemMessage(table.concat(queue, "\n"))
	end
end)

(Tho don’t close this report if this helps. I think Roblox should still address this)

1 Like

Linking a bug report I made about sent chat messages appearing in the wrong location for the sender as it was considered a duplicate:

I assume the same cause is behind this issue with both chat messages and system messages.

This issue still occurs pretty regularly, since last July:


Here, I chatted “didnt see a carrier” after “i watched intro”, but the later message appeared in a random unrelated place in the window.