Help with message being sent ion chat


I was wondereing how I could make a message be sent in the chat. Here is my current script but it doesn’t work:

local success, errormsg = pcall(function()
	game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",  { Text = "[SYSTEM] Hello World", Color = Color3.fromRGB( 255,0,0 ), Font = Enum.Font.Arial, FontSize = Enum.FontSize.Size24 } )

if errormsg then

That would perfectly fine in the legacy chat. TextChatService needs a bit different approach. Take a look at this video: How to make SYSTEM MESSAGES in the NEW CHAT in ROBLOX (TextChatService) - YouTube .

1 Like

Thanks for the help but it still doesn’t work. Here is the updated script:

local function getSystemMsg(MsgDict: array)
	return '<font color="#'..MsgDict["Color"]..'"><font size="'..MsgDict["FontSize"]..'"><font face="'..MsgDict["Font"]..'">'..MsgDict["Text"]..'</font><font></font>'

local channel = ChatService:WaitForChild("RBXSystem")
                   Text = "THIS IS A TEST";
				Font = "Gotham";
				Color = Color3.fromRGB(255,0,0):ToHex();
				FontSize = "17";

As it turns out, the channels may not be fully loaded by the time message is sent.

-- Simplified version
local TextChatService = game:GetService("TextChatService")
local SystemChannel = TextChatService:WaitForChild("TextChannels"):WaitForChild("RBXSystem")

	print(message) --> prints the instance

local sentMsg = SystemChannel:DisplaySystemMessage("Hello, World!")
print(sentMsg) --> prints the instance

For testing purposes, task.wait(1) before calling :DisplaySystemMessage() worked, although I don’t like “magic numbers” and yielding with wait() to fix the code. When I can, I’ll do some more research to find a better solution than yielding with a guess.

1 Like

I could try that but it’s not being called straight away. I have just showed the part that handles the message. I get an error in the console: Infinite yield possible on 'TextChatService:WaitForChild("RBXSystem")'

This script is in StarterGui because it also handles UI

I have resolved the issue! I was doing ChatService:WaitForChild("RBXSystem") instead of ChatService:WaitForChild(“TextChannels”):WaitForChild(“RBXSystem”)

Ay, you actually unknowingly fixed your problem!

This function works once the GUIs are loaded, which means it can’t work right away in StarterPlayerScripts. The GUIs first need to be replicated into player.PlayerGui.

Check the code again, there’s :WaitForChild("TextChannels") missing.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.