I have to migrate from LegacyChatService to TextChatService and SetCore only works with Legacy. I got it to actually make messages now but I need to fix them not having colors please help thanks
local event = game.ReplicatedStorage:WaitForChild("ServerToClientChat")
local TextChatService = game:GetService("TextChatService")
local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral
event.OnClientEvent:Connect(function(givenText,givenBrickColor)
--[[ -- this was used for LegacyCHatService
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = givenText;
Font = Enum.Font.SourceSansBold;
Color = givenBC;
FontSize = Enum.FontSize.Size96;
})
--]]
generalChannel:DisplaySystemMessage(givenText)
end)
Edit: for any future viewers here is what i changed in the above script
You need to to use the metadata field generalChannel:DisplaySystemMessage(givenText, metadata), to then, within a function binded to TextChatService.OnIncomingMessage (or TextChannel.OnIncomingMessage, do something like this
local TextChatService = game:GetService("TextChatService")
TextChatService.OnIncomingMessage = function(message : TextChatMessage)
local Metadata = message.Metadata
if Metadata == "WhateverYouWantToAsignIt" then
local properties = TextChatService.ChatWindowConfiguration:DeriveNewMessageProperties()
properties.TextColor3 = Color3.fromRGB(255, 121, 121)
properties.FontFace = Font.fromEnum(Enum.Font.SourceSansBold)
properties.TextSize = 96 -- This is like, really big?
-- Set chat window message properties
-- (Don't know what it does)
message.ChatWindowMessageProperties = properties
return properties
end
end
Thanks for your help! I adjusted my local script in case any viewers wants to just use mine
local event = game.ReplicatedStorage:WaitForChild("ServerToClientChat")
local TextChatService = game:GetService("TextChatService")
local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral
local nextMetaID = 1
local msgList = {} -- using a table makes sure that the given color doesnt just go to the first new message in chat instead of the target
TextChatService.OnIncomingMessage = function(message: TextChatMessage)
-- check if new message in chat is a target message with color
if message.Metadata == "" then -- normal chat messages wont have any metadata
return
end
if msgList[message.Metadata] then
local properties = TextChatService.ChatWindowConfiguration:DeriveNewMessageProperties()
properties.TextColor3 = msgList[message.Metadata]
properties.FontFace = Font.fromEnum(Enum.Font.SourceSansBold)
message.ChatWindowMessageProperties = properties
msgList[message.ChatWindowMessageProperties.Text] = nil -- clear entry to prevent memory leak
end
end
event.OnClientEvent:Connect(function(givenText,givenBrickColor)
local meta = nextMetaID
meta = tostring(meta)
nextMetaID+=1
msgList[meta] = givenBrickColor -- save the text color in a list marked with the meta value
generalChannel:DisplaySystemMessage(givenText,meta)
end)
Note: This is a local script, a server script fires a remote event to all clients with the message text and color data