In the image above I have already been able to update the colour of my name to a darker red, which is fine- however when I go into team chat the original team colour remains. I’ve tried a few things by asking chatgpt (very useless in this case lol), including setting the prefix to just “”, including prefix in the message, etc.
this is my code rn:
tcs.OnIncomingMessage = function(message:TextChatMessage)
if not message.TextSource then return end
local player = players:GetPlayerByUserId(message.TextSource.UserId)
if not player then return end
local properties = Instance.new("TextChatMessageProperties")
local Color = nil
local Team = player.Team
if Team then
Color = Team:GetAttribute("DisplayCol")
if Color == Color3.fromRGB(255,255,255) then Color = nil end
Color = Color or Team.TeamColor.Color
end
if Color then
properties.PrefixText = tostring(string.format("<font color = \"#%s\">["..player.Name.."]:</font>", tostring(Color:ToHex())))
end
return properties
end
If this isn’t possible because it’s a roblox CoreGui thing, are there any workarounds that I can do? I considered blocking the message and sending it manually but I don’t really know how to do that with this new stuff and it feels like that’d overcomplicate the problem anyway.
Yes I could just change the teamcolor, but I have reasons for not doing that (this is just one example)
Since Team-chat is a TextChannel, you have to specify TextChannel.OnIncomingMessage as it fires afterTextChatService.OnIncomingMessage and is where it adds the “[Team]” prefix.
First you need to get the TextChannel of a given team. The naming scheme of which uses the Team.TeamColor property for some reason, so this may break if you have multiple teams with the same TeamColor…?
local txtChannels = tcs:WaitForChild("TextChannels")
task.wait(2) -- We need to wait for roblox to load in the default OnIncomingMessage so we can overwrite it
for _, Team: Team in pairs(game:GetService("Teams"):GetTeams()) do
local teamTxtChannel = txtChannels:WaitForChild("RBXTeam" .. tostring(Team.TeamColor))
-- Your custom display color, defaults to Team.TeamColor when white
local Color = Team:GetAttribute("DisplayCol")
if Color == Color3.fromRGB(255, 255, 255) then Color = Team.TeamColor.Color end
teamTxtChannel.OnIncomingMessage = function(message: TextChatMessage)
if not message.TextSource then return end
local player = players:GetPlayerByUserId(message.TextSource.UserId)
if not player then return end
local properties = Instance.new("TextChatMessageProperties")
properties.PrefixText = tostring(string.format("<font color = \"#%s\">[Team] ["..player.Name.."]:</font>", tostring(Color:ToHex())))
return properties
end
end