Originally wanted to help a user out but in the end he ran into a problem that was not caused by him, but by Roblox Studio itself.
Link to original forum post, which made me discover the bug: /tog to toggle chattag - #4 by kwkxbxkdkdjjd
Roblox Studio Version: 0.664.0.6640713 (latest version available)
Roblox Studio Beta Programs: “Dragger QoL Improvements”
100% Reproduction Chance.
Place File:
textchatservice_bug.rbxl (55.1 KB)
What happens? If you type something in chat and have a function hooked onto an OnIncomingMessage Callback on the TextChatService, the function will run twice per message for no apparent reason.
Reproduction Steps:
Open the Roblox Place file above and playtest it. Write something in the chat. The script (located in StarterPlayer > StarterPlayerScripts) will print out the content of the message sent, the timestamp and the MessgeID, which is a unique identifier of a Text Message(!)
If you type something in the chat you will see output like two message were sent, though only one was sent in reality.
Output Explained:
First line: message.Text
Second line: message.Timestamp
Third line: message.MessageId
Fourth line: Seperating Hyphens to indicate that the function runtime ends here
As can be seen in the image above, when looking in the Text Chat, I only sent 1 message, but in the output there are 2 blocks with the same Text Content, the SAME MessageID and a slightly different Timestamp value.
The main factor here is the MessageID. It prooves that this is about the exact same message.
System Information:
OS: Windows 11 Pro (Build 26100.3194)
CPU: Intel Core i7-13620H
RAM: 16GB DDR5 SDRAM 5200MHz (I had enough Standby and Free RAM Memory according to resmon and RAMMap)
dGPU: Nvidia GeForce RTX 4070 (running on latest Game-Ready Drivers)
iGPU: Intel Raptor Lake-P - Integrated Graphics (Raptor Lake-P/U GT2)
I have had no problems in the past with Roblox Studio regarding my system. I have nothing overclocked or undervolted. I keep my drivers up to date.
Expected behavior
I would expect the Callback to only run my function once per message as it seems to be explained behavior in the TextChatService Documentation.