From what I remember you take your message and assign it to textchatproperties.Text and then return it from the fn
edit:
--like so:
--this colors all messages black
game.TextChatService.OnIncomingMessage = function(msg: TextChatMessage)
local metadata = Instance.new("TextChatMessageProperties")
metadata.Text = string.format('<font color="#000000">%s</font>', msg.Text)
return metadata
end
no wait, you need to return it from either the TextChatService.OnIncomingMessage or the TextChannel.OnIncomingMessage callback function, which you can implement on the client, and then in your current script you just send your message normally:
injuryAnnouncementEvent.OnClientEvent:Connect(function(playerName, injuryType, sitOutTime)
systemChannel:SendAsync(playerName)
end)
--this callback is used to decorate messages before they are displayed
--every message send from this channel will have these decorations applied
--if you want all messages to have this style use TextChatService.OnIncomingMessage instead
systemChannel.OnIncomingMessage = function(msg: TextChatMessage)
local data = instance.new("TextChatMessageProperties")
data.Text = string.format('<font color="#000000">%s</font>', msg.Text)
return data
end
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextChatService = game:GetService("TextChatService")
local injuryAnnouncementEvent = ReplicatedStorage:WaitForChild("IAE")
local healRE = ReplicatedStorage:WaitForChild("HealRE")
local systemChannel = TextChatService:FindFirstChild("RBXSystem") -- System channel for announcements
-- Ensure the system channel exists
if not systemChannel then
systemChannel = Instance.new("TextChannel")
systemChannel.Name = "RBXSystem"
systemChannel.Parent = TextChatService
--systemChannel.RichText = true
end
injuryAnnouncementEvent.OnClientEvent:Connect(function(playerName, injuryType, sitOutTime)
systemChannel:SendAsync(playerName)
end)
systemChannel.OnIncomingMessage = function(msg: TextChatMessage)
local data = Instance.new("TextChatMessageProperties")
data.Text = string.format('<font color="#000000">%s</font>', msg.Text)
return data
end
well it sends your name because I changed it to pass playerName to systemChannel:SendAsync because I don’t actually know what your message is sorry. Just change that to your message here:
injuryAnnouncementEvent.OnClientEvent:Connect(function(playerName, injuryType, sitOutTime)
systemChannel:SendAsync("YOUR MESSAGE")--replace this
end)
--this callback is used to decorate messages before they are displayed
--every message send from this channel will have these decorations applied
--if you want all messages to have this style use TextChatService.OnIncomingMessage instead
systemChannel.OnIncomingMessage = function(msg: TextChatMessage)
local data = instance.new("TextChatMessageProperties")
data.Text = string.format('<font color="#000000">%s</font>', msg.Text)
return data
end
Well do you want to display all three arguments?
You could do:
systemChannel:SendAsync(string.format("%s, %s, %d", playerName, injuryType, sitOutTime))--assuming injurytype is a string
I don’t understand what you want to send exactly, but I don’t need to know since you can just replace whatever is in the sendasync call with what you want to send
Thanks! That helps, but now I’m back at square one because it won’t color.
systemChannel:SendAsync(string.format('%s has been injured from a "<font color="#000000">%s</font>"! They must sit out for %d minute(s).', playerName, injuryType, sitOutTime))--assuming injurytype is a string
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextChatService = game:GetService("TextChatService")
local injuryAnnouncementEvent = ReplicatedStorage:WaitForChild("IAE")
local healRE = ReplicatedStorage:WaitForChild("HealRE")
local systemChannel = TextChatService:FindFirstChild("RBXSystem") -- System channel for announcements
-- Ensure the system channel exists
if not systemChannel then
systemChannel = Instance.new("TextChannel")
systemChannel.Name = "RBXSystem"
systemChannel.Parent = TextChatService
--systemChannel.RichText = true
end
injuryAnnouncementEvent.OnClientEvent:Connect(function(playerName, injuryType, sitOutTime)
systemChannel:SendAsync(string.format('%s has been injured from a "<font color="#000000">%s</font>"! They must sit out for %d minute(s).', playerName, injuryType, sitOutTime))--assuming injurytype is a string
end)
systemChannel.OnIncomingMessage = function(msg: TextChatMessage)
local data = Instance.new("TextChatMessageProperties")
data.Text = string.format('<font color="#000000">%s</font>', msg.Text)
return data
end
okay so I took your code and it seems like richtext doesn’t work on RBXSystem, and the only reason it worked was because you create a custom one if RBXSystem doesn’t exist, btw this is how you get RBXSystem:
local systemChannel = TextChatService:WaitForChild("TextChannels"):WaitForChild("RBXSystem")
anyway so if you create a custom textchannel instead and use that it should work.
edit: also like someone else pointed out it is better to use DisplaySystemMessage since it will not have chat bubbles pop up, it will still trigger OnIncomingMessage decorators so you don’t need to change that, although you can just use <font> directly in DisplaySystemMessage like so:
systemChannel:DisplaySystemMessage(string.format('%s has been injured by <font color="#FF0000">%s</font>. They must sit out for %d minute(s)', playerName, injureType, sitOutTime))
systemChannel:SetAsync(string.format('%s has been injured from a "<font color="#000000">%s</font>"! They must sit out for %d minute(s).', playerName, injuryType, sitOutTime))--assuming injurytype is a string
YOU USE
systemChannel:DisplaySystemMessage(string.format('%s has been injured from a "<font color="#000000">%s</font>"! They must sit out for %d minute(s).', playerName, injuryType, sitOutTime))--assuming injurytype is a string