i am attempting to add simple chat tags and the code works fine in studio but when I attempt to play it in the actual game I get the error “attempt to index nil with SetExtraData”.
chatService.SpeakerAdded:Connect(function(playerName)
local roleInGroup = player:GetRoleInGroup(4946462)
local player = game.Players[playerName]
if roleInGroup ~= "Guest" then
local overheadUI = ReplicatedStorage.Assets.Gui.OverheadUI:Clone()
overheadUI.Main.Label.Text = roleInGroup
overheadUI.Main.Label.TextColor3 = playerTitleColors[roleInGroup]
if player.Character == nil then
local connection
connection = player.CharacterAdded:Connect(function(char)
overheadUI.Parent = char.Head
connection:Disconnect()
end)
else
overheadUI.Parent = player.Character.Head
end
local speaker = chatService:GetSpeaker(player.Name)
speaker:SetExtraData("Tags", {playerChatTags[roleInGroup]})
end
end)