Trying to change chat colour on every team

I’m stuck trying to make every team chat colour different, but I can’t figure it out. Can someone help?

local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

ChatService.SpeakerAdded:Connect(function(PlayerName)
	ChatService:GetSpeaker(PlayerName):SetExtraData("ChatColor", Players[PlayerName].TeamColor.Color)
end)

for Index, Team:Team in pairs(Teams:GetTeams()) do
	Team.PlayerAdded:Connect(function(Player)
		ChatService:GetSpeaker(Player.Name):SetExtraData("ChatColor", Team.TeamColor.Color)
	end)
end

this post sample code also shows how to set other datas such as adding tags

1 Like