Custom Chat Tags not working

So I have this script

local MPS = game:GetService("MarketplaceService")
local IS = game:GetService("InsertService")
local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Players = game:GetService("Players")

local Item1 = 112591865
local Item2 = 162857357

ChatService.SpeakerAdded(function(playerObj)
	local Speaker = ChatService:GetSpeaker(playerObj)
	if MPS:UserOwnsGamePassAsync(playerObj.UserId, 9898859) then
		Speaker:SetExtraData("Tags", {{TagText = "POPPIN EXCLUSIVE", TagColor = BrickColor.new("Really red").Color}})
	end
end)

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if MPS:UserOwnsGamePassAsync(player.UserId, 9898859) then
			local Gear1 = IS:LoadAsset(Item1)
			local Gear2 = IS:LoadAsset(Item2)
			Gear1:FindFirstChildOfClass("Tool").Parent = player.Backpack
			Gear2:FindFirstChildOfClass("Tool").Parent = player.Backpack
		end
	end)
end)

But whenever I run it I get this error

Attempt to call a userdata value

on this line

ChatService.SpeakerAdded(function(playerObj)

Can anyone help me?

1 Like

Are they game pass tags? If so I might know how to fix.

@Barty200, are they game pass chat tags, or are they certain player tags?

1 Like

Yes they are but it’s not a problem checking if the player owns a gamepass

1 Like

Okay, just a second, I’m opening up my game and taking the script.

Should it be

ChatService.SpeakerAdded:Connect(function(playerObj)
-- --ROBLOX STUDIO TUTORIAL--
--https://youtu.be/Pctc8ryB0tk--
--If you  buy the gamepass playing the game , close and open the chat or reset!
--Thanks for use this for your game :3--


local gamepassId = 8556793 -- ID of your gamepass
local service = game:GetService("MarketplaceService") --  Buy the gamepass  ( Dont delete  )
game.Players.PlayerAdded:Connect(function(player)
    if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then -- If you buy the gamepass playing the game
        local tags = {
            {
                TagText = "VIP", -- Change this to your gamepass name or tag name!
                TagColor = Color3.fromRGB(0, 255, 255) -- Change this to your color tag!
            }
        }
        local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
        local speaker = nil
        while speaker == nil do
            speaker = ChatService:GetSpeaker(player.Name)
            if speaker ~= nil then break end
            wait(0.01) -- Dont change this or ur game can crash!
        end
        speaker:SetExtraData("Tags",tags) -- Extra data  ( Extra data is roblox filtering  chat "#" this  is t h e color of   chat tags)
        speaker:SetExtraData("ChatColor",Color3.fromRGB(255, 255, 0)) -- Change this to  your color texts and tags!
    end
end)

Try that.

1 Like

I would recommend replacing the PlayerAdded event with the SpeakerAdded event.

A note: SpeakerAdded fires with a string, not a player instance. You need to correct this by first getting the speaker associated with the speaker, then the player if applicable.

ChatService.SpeakerAdded:Connect(function (speakerName)
    local speaker = ChatService:GetSpeaker(speakerName)
    local player = speaker:GetPlayer()

    if player and MPS:UserOwnsGamePassAsync(player.UserId, 9898859) then
        speaker:SetExtraData("Tags", {{TagText = "POPPIN EXCLUSIVE", TagColor = BrickColor.new("Really red").Color}})
    end
end)

Yeah I figured it out but thanks anyway