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
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)
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)