I have this script to assign chat tags to people with certain ranks in my group, yet it cant seem to find the speaker in game yet it finds it without problem in studio. Can someone help me on how to fix this?
My script:
local ChatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local function CREATE_CHAT_TAG(player, name, color)
local Speaker = ChatService:GetSpeaker(player.Name)
Speaker:SetExtraData("Tags", {{TagText = name, TagColor = color}})
end
game.Players.PlayerAdded:Connect(function(player)
local GROUP_ID = 12905243
local RANK = player:GetRoleInGroup(GROUP_ID)
if RANK == "Universal Traveler" then
CREATE_CHAT_TAG(player, "The Quantum Physicist", Color3.fromRGB(133, 85, 255))
elseif RANK == "Builder Traveler" then
CREATE_CHAT_TAG(player, "The Physicist", Color3.fromRGB(166, 219, 255))
elseif RANK == "Animator Traveler" then
CREATE_CHAT_TAG(player, "The Anatomist", Color3.fromRGB(255, 110, 112))
elseif RANK == "Admin Traveler" then
CREATE_CHAT_TAG(player, '"OBSERVER"', Color3.fromRGB(78, 60, 97))
elseif RANK == "Tester Traveler" then
CREATE_CHAT_TAG(player, "Assistant", Color3.fromRGB(122, 227, 197))
end
end)