Chat tag works for me, but not for some people

I have this script which manages chat tags, which specifies a chat tag for staff members and one for vip gamepass owners. I am specified here and own vip, and my owner one overrides the vip. However, some mods can’t see their tags. Why is this? The entries are the same.

local MarketplaceService = game:GetService("MarketplaceService")

local ChatServiceRunner = ServerScriptService:WaitForChild("ChatServiceRunner")
local ChatService = require(ChatServiceRunner.ChatService)

-- Create a dictionary of special chat data (e.g. mods).
local SPECIAL_CHAT_DATA = {
    -- I will only fill out one dictionary key for you as an example, do
    -- the rest on your own time.
    [776294655] = {
        ChatColor = Color3.new(14, 76, 98),
        Tags = {
            {TagText = "Creator", TagColor = Color3.fromRGB(14, 76, 98)},
        }
    },
    [387060256] = {
        ChatColor = Color3.new(85, 170, 255),
        Tags = {
            {TagText = "Melon Shark", TagColor = Color3.fromRGB(85, 170, 255)},
        }
    },
    [157066100] = {
        ChatColor = Color3.new(255,255,0),
        Tags = {
            {TagText = "Moderator", TagColor = Color3.fromRGB(255,255,0)},
        }
    },
    [278133397] = {
        ChatColor = Color3.new(34,139,34),
        Tags = {
            {TagText = "Moderator", TagColor = Color3.fromRGB(34,139,34)},
        }
    },
    [246403810] = {
        ChatColor = Color3.new(221,214,225),
        Tags = {
            {TagText = "Moderator", TagColor = Color3.fromRGB(221,214,225)},
        }
    },
    [144157339] = {
        ChatColor = Color3.new(0,255,0),
        Tags = {
            {TagText = "Developer", TagColor = Color3.fromRGB(0,255,0)},
        }
    },
    [125293735] = {
        ChatColor = Color3.new(255,0,0),
        Tags = {
            {TagText = "Creator", TagColor = Color3.fromRGB(255,0,0)},
        }
    },
    [1498144377] = {
        ChatColor = Color3.new(0,35,102),
        Tags = {
            {TagText = "Developer", TagColor = Color3.fromRGB(0,35,102)},
        }
    },
    [413969295] = {
        ChatColor = Color3.new(0, 0, 255),
        Tags = {
            {TagText = "Moderator", TagColor = Color3.fromRGB(85, 170, 255)},
        }
    },
    [413969295] = {
        ChatColor = Color3.new(128,0,0),
        Tags = {
            {TagText = "Moderator", TagColor = Color3.fromRGB(128,0,0)},
        }
    },
    [1037666502] = {
        ChatColor = Color3.new(0, 0, 255),
        Tags = {
            {TagText = "Creator", TagColor = Color3.fromRGB(85, 170, 255)},
        }
    },
    [157066100] = {
        ChatColor = Color3.new(255,255,0),
        Tags = {
            {TagText = "Moderator", TagColor = Color3.fromRGB(255,255,0)},
        }
    },
    -- etc
}

-- Again, make a table as a constant so you can edit here instead of
-- in a function. Your original code was creating tables every time
-- the function was called, which isn't good anyhow.
local VIP_CHAT_DATA = {
    ChatColor = Color3.fromRGB(239, 184, 56),
    Tags = {
        {TagText = "VIP", TagColor = Color3.fromRGB(239, 184, 56)},
    },
}

-- So if we need to change the pass, we can do it from here instead of
-- further into the code where it's less visible.
local GAME_PASS_ID = 9326348

-- Small tip: for the above tables, you can make submodules that return tables
-- on require. Would keep giant tables from being in the tags script.

-- To make things cleaner for us, to isolate this assignment bit and
-- to clearly show for example's sake, created this function.
local function applyExtraDataForSpeaker(speaker, dataTable)
    for key, value in pairs(dataTable) do
        speaker:SetExtraData(key, value)
    end
end

-- Make sure to create a function like this. To catch speakers who may be added
-- ahead of SpeakerAdded being registered, some may not get tags.
local function speakerAdded(speakerName)
    local speaker = ChatService:GetSpeaker(speakerName)
    -- Player is available here! Do not use Players service!
    local player = speaker:GetPlayer()

    -- If this is a player speaker, proceed
    if player then
        -- Keep this flag handy for later.
        local dataAddressed = false

        -- Look for special data first: if they have it, apply it
        local specialData = SPECIAL_CHAT_DATA[player.UserId]

        if specialData then
            applyExtraDataForSpeaker(speaker, specialData)
            -- Flip our earlier flag dataAddressed for the if statement below
            dataAddressed = true
        end

        -- Use the flag to determine if we should evaluate VIP next
        if not dataAddressed then
            local isVIP = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GAME_PASS_ID)

            -- If the player owns the VIP pass, give them VIP chat data. Our
            -- earlier flag isn't needed anymore, so don't set it here.
            if isVIP then
                applyExtraDataForSpeaker(speaker, VIP_CHAT_DATA)
            end
        end
    end
end

-- Hook the speakerAdded function to the SpeakerAdded event
-- and make sure all added speakers who didn't have
-- SpeakerAdded fired for them, gets the function called on them.
ChatService.SpeakerAdded:Connect(speakerAdded)
for _, speakerName in ipairs(ChatService:GetSpeakerList()) do
    speakerAdded(speakerName)
end```

I recognise this code: I’m pretty sure it’s the one I wrote some time back.

The idea I had in mind here was that a developer’s tag would supersede the VIP one, so the VIP tag won’t show up if you also give the user special chat data. As for some of your users not seeing tags, you need to provide more information such as if there was any issues in the console. When writing threads for this category, always be detailed in explaining an issue. Vague explanations aren’t helpful.

If you want VIP tags to be added regardless of if a user has special data to be registered or not, you can opt instead to create a table worth all the player’s potential tags. You can then check if they are in the dictionary and if they are, insert the tags to the table. Then, evaluate their VIP state and if they have VIP, add the chat tag as well (preferably at position 1 for UX’s sake). You can then apply all that from SetExtraData to the ChatSpeaker.

Well, their tag doesn’t show up at all, even though the entry is the same format.

That’s not a significant amount of information to go off of and this is already available in the OP. Please review my post. I’m looking for things such as console information and what potential debugging strategies you’ve tried so far as well as what’s happened in that respect. :slight_smile:

There doesn’t seem to be anything acting up in console then or when the affected player joins, and I’ve looked at the tag script, which is exactly the same as the ones that work.

Could you check and make sure you don’t have duplicate indices in your table, first and foremost? This chat tag code shouldn’t be unworking considering I tested it before, however I do notice now that you have several duplicate entries in the dictionary.

When you want to add more custom tags to users, you need to be adding more tags through their Tags table and not by adding a key of the same index as another. For example, I can see the UserId 157066100 repeated twice in your dictionary. If you wanted to add an extra tag, you should have a new table:

Tags = {
    {tagData},
    {tagData}
}

There could be overwriting that you aren’t catching, hence why “some” of your users do not get the special tags you have down for them.

I have removed the duplicates, but user 157066100 still missing his tag.