Roblox System Messages

How do I send system messages with the new chat? I want to have multiple that it chooses between every 5 minutes, with a color of choice.

3 Likes

This should help: TextChatService | Documentation - Roblox Creator Hub

And this is a basic code block to help:

-- services
local textChatService: TextChatService = game:GetService("TextChatService")

-- variables
local textChannels: Folder = textChatService:WaitForChild("TextChannels", 100) :: Folder
local generalChannel: TextChannel = textChannels:WaitForChild("RBXGeneral", 100) :: TextChannel

local chatMessages: any = {
	"Wow",
	"Cool",
	"Message",
}

-- functions
while (true :: boolean) do
	generalChannel:DisplaySystemMessage(chatMessages[math.random(#chatMessages)])
	
	task.wait(360)
end
1 Like

Not a scripter, how do I change the color?

This post should help: How do I change System Text's Color on the new TextChatService? - #3 by be_nj ( Reply back if you’re still confused )


Where would I put it?

1 Like

Okay, I don’t normally give out code because I think people should learn for themselves, however this is quite simple:

-- services
local textChatService: TextChatService = game:GetService("TextChatService")

-- variables
local textChannels: Folder = textChatService:WaitForChild("TextChannels", 100) :: Folder
local systemChannel: TextChannel = textChannels:WaitForChild("RBXSystem", 100) :: TextChannel

local chatMessages: any = {
	{
		Text = "This is a test!",
		Color = Color3.fromRGB(49, 173, 255),
	},
	{
		Text = "This is another test!",
		Color = Color3.fromRGB(255, 85, 79),
	},
}

local timePerMessage: number = 60 * 5

-- functions
while (true :: boolean) do
	-- select a random message data
	local randomMessageData: any = chatMessages[math.random(#chatMessages)]
	
	-- using math.floor so no floats ruin the message.
	local r: number = math.floor(randomMessageData.Color.R * 255)
	local g: number = math.floor(randomMessageData.Color.G * 255)
	local b: number = math.floor(randomMessageData.Color.B * 255)
	
	-- combine the final string together
	local randomMessage = "<font color='rgb(" .. r .. "," .. g .. "," .. b .. ")'>" .. randomMessageData.Text .. "</font>"
	
	-- display the message in chat
	systemChannel:DisplaySystemMessage(randomMessage)
	
	-- wait until the next message ...
	task.wait(timePerMessage)
end

Place this into a LocalScript in StarterPlayerScripts. You can change/add/remove messages from the chatMessages table seen on line 8.

In the chatMessages table, just copy and paste one of the already added tables; then change the text and color to what you desire.

Reply if something doesn’t work.

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