Team Color check not working

So I’m working on improving my scripting skills and I ran into a little issue while playing around with ChatService; When I tried adding a correct team check, the script didn’t assign the changes I wrote. Any idea how I can resolve my issue?

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


ChatService.SpeakerAdded:Connect(function(SpeakerName)
	print(SpeakerName)
	wait(5)
	print(SpeakerName)
	if SpeakerName and SpeakerName.TeamColor == BrickColor.new("Really red") then
		local Speaker = ChatService:GetSpeaker(SpeakerName)
		local player = players:WaitForChild(SpeakerName)
		Speaker:SetExtraData("Tags", {{TagText = "text", TagColor = Color3.fromRGB(161, 165, 119)}})
		Speaker:SetExtraData("NameColor", Color3.fromRGB(255, 255, 255))
		Speaker:SetExtraData("ChatColor", Color3.fromRGB(255, 255, 255))
	end
end)

EDIT: The team(Really red color) is set to auto-assignable

You can’t get the Team of a string value, you need to use the string to find the player first.

Speaker = ChatService:GetSpeaker(SpeakerName)

if Speaker and Speaker.TeamColor == BrickColor.new("Really red") then

1 Like

Didn’t really seem to work:

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


ChatService.SpeakerAdded:Connect(function(SpeakerName)
	print(SpeakerName)
	local Speaker = ChatService:GetSpeaker(SpeakerName)
	if Speaker and Speaker.TeamColor == BrickColor.new("Really red") then
		local player = players:WaitForChild(SpeakerName)
		Speaker:SetExtraData("Tags", {{TagText = "text", TagColor = Color3.fromRGB(161, 165, 119)}})
		Speaker:SetExtraData("NameColor", Color3.fromRGB(255, 255, 255))
		Speaker:SetExtraData("ChatColor", Color3.fromRGB(255, 255, 255))
	end
end)

Am I doing it wrong?

1 Like

Nevermind, fixed it!

As @polill00 mentioned above, I mentioning a string value and not the actual player, fixed it by using
local Speaker = players:FindFirstChild(SpeakerName)
insead of
local Speaker = ChatService:GetSpeaker(SpeakerName)

Sorry, yes I’ve done some documentation research and to get the player from GetSpeaker you need to do

local Speaker = ChatService:GetSpeaker(SpeakerName)
local player = Speaker:GetPlayer()