CreateCoreMessage / CreateServerMessage

So if you’re looking to add multiple colors to messages and i assume you want it to display when a player joins i can help!

  1. Add a RemoteEvent in ReplicatedStorage
  2. Add a Script in ServerScriptService
  3. Add a Module Script inside your Local Script and name it ChatColor to make things easier

Inside your Script, add this to fire an event to the player when their character is added.

--<< Services >>--
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--<< Variables >>--
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

--<< Code >>--
Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		RemoteEvent:FireClient(player)
		-- We fire this when the player's character loads because TextChatService isn't fully loaded when the player just joins
	end)
end)

Inside your Local Script, add this! We’ll grab the ChatColor module we created to make the DisplaySystemMessage custom colors and we’ll create a function that’s called displayMessage to connect to our RemoteEvent and use OnClientEvent. It’s your choice to choose between GeneralChannel or SystemChannel! You can learn more about these Default Channels here.

--<< Services >>--
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--<< Variables >>--
local ChatColor = require(script.ChatColor)
local GeneralChannel: TextChannel = TextChatService:FindFirstChild("RBXGeneral", true)
local SystemChannel: TextChannel = TextChatService:FindFirstChild("RBXSystem", true)
local RemoveEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

--<< Code >>--
local function displayMessage()
	GeneralChannel:DisplaySystemMessage("I want the " .. ChatColor.Orange .. "orange" .. ChatColor.End .. " candy.")
end

RemoveEvent.OnClientEvent:Connect(displayMessage)

Inside your Module Script, add this! We will define each color in it’s rgb color value with RichText and use Chat.End to close it off and make it easier to manage.

--<< Example: '<font color="rgb(0,0,0)">' >>--

local ChatColor = {}

ChatColor.Orange = '<font color="rgb(255, 120, 0)">'
ChatColor.End = '</font>'

return ChatColor

The End Result should look like this:

TextChatServiceMultipleColorsSystemMessage

Hopefully this helps in some way and can make you have a better understanding of it!

3 Likes

12:32:59.184 Players.NotBugle.PlayerScripts.RoLX:15: attempt to index nil with 'DisplaySystemMessage' - Client - RoLX:15

Fixed your script.

--<< Services >>--
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--<< Variables >>--
repeat task.wait() until TextChatService:WaitForChild("TextChannels", 0.1)
local Channels = TextChatService:WaitForChild("TextChannels", 0.1)
local GeneralChannel: TextChannel = Channels:WaitForChild("RBXGeneral", 1)
local SystemChannel: TextChannel = Channels:WaitForChild("RBXSystem", 1)
local RoLX_ReplicatedStorage: Folder = ReplicatedStorage:WaitForChild("RoLX", 1)
local RoLX_Events: Folder = RoLX_ReplicatedStorage:WaitForChild("Events", 1)
local RoLX_DisplayMessage: RemoteEvent = RoLX_Events:WaitForChild("DisplayMessage", 1)

--<< Code >>--
local function displayMessage(message: string)
	GeneralChannel:DisplaySystemMessage(message)
end

RoLX_DisplayMessage.OnClientEvent:Connect(displayMessage)