Gamepass chat tag doesnt work

this script is supossed to add a chat tag to the owner of this gamepass and a chat color, the chatcolor works but theres no chattag, help?

local ServerScriptService = game:GetService("ServerScriptService")
local MarketplaceService = game:GetService("MarketplaceService")

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

local GAME_PASS_ID = 25754586

local VIP_TAGS = {
	{
		TagText = "đź‘‘VIP",
		TagColor = Color3.new(0, 1, 1)
	}
}

local function speakerAdded(speakerName)
	local speaker = ChatService:GetSpeaker(speakerName)
	local player = speaker:GetPlayer()

	-- ChatSpeaker belongs to a player entity
	if player then
		local success, hasPass = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, player.UserId, GAME_PASS_ID)
		--local success, hasPass = true, true
		if success and hasPass then
			speaker:SetExtraData("Tags", VIP_TAGS)
			speaker:SetExtraData("ChatColor", Color3.fromRGB(0, 226, 226))
		end
	end
end

ChatService.SpeakerAdded:Connect(speakerAdded)
for _, speaker in ipairs(ChatService:GetSpeakerList()) do
	speakerAdded(speaker)
end
1 Like
local gamepassId = 000000 -- Gamepass ID
local Players = game:GetService('Players')
local SSService = game:GetService('ServerScriptService')
local MPService = game:GetService("MarketplaceService")
local ChatService = require(SSService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

ChatService.SpeakerAdded:Connect(function(PlayerName)
	local player = Players:FindFirstChild(PlayerName)
	local hasPass
	if player then
		hasPass = MPService:UserOwnsGamePassAsync(player.UserId, gamepassId)
	end
	local Speaker = ChatService:GetSpeaker(PlayerName)
	local success, hasPass = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, player.UserId, GAME_PASS_ID)
		--local success, hasPass = true, true
		if success and hasPass then
-- Everything Below this line is customizable
		Speaker:SetExtraData('NameColor', Color3.fromRGB(255, 255, 255))
		Speaker:SetExtraData('ChatColor', Color3.fromRGB(0, 226, 226))
		Speaker:SetExtraData('Tags', {{TagText = 'đź‘‘VIP', TagColor = Color3.fromRGB(0, 1, 1)}})
	end
end)
2 Likes

still doesnt work, screenshot:

image

(apologies for late response)

1 Like

Make sure its a Server Script (Regular Script) in ServerScriptService. NOT a local script.

Also, did you put the correct gamepass ID in the variable in my script right?

1 Like

Hello there! I tested your script by replacing if success and hasPass then by if true then and it works fine for me, so I assume the error is coming from the part where you are checking if the player owns the gamepass.
image

You redefined “hasPass” and then pcalled the MarketplaceService method, which errored as well because you passed a nil value for the gamepass ID (GAME_PASS_ID is not defined in your script)

Right. I’m dumb. Here is the right script:

local gamepassId = 000000 -- Gamepass ID
local Players = game:GetService('Players')
local SSService = game:GetService('ServerScriptService')
local MPService = game:GetService("MarketplaceService")
local ChatService = require(SSService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

ChatService.SpeakerAdded:Connect(function(PlayerName)
	local player = Players:FindFirstChild(PlayerName)
	local Speaker = ChatService:GetSpeaker(PlayerName)
	local hasPass
	if player then
		hasPass = MPService:UserOwnsGamePassAsync(player.UserId, gamepassId)
	end
	local success, hasPass = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, player.UserId, gamepassId)
		--local success, hasPass = true, true
		if success and hasPass then
-- Everything Below this line is customizable
		Speaker:SetExtraData('NameColor', Color3.fromRGB(255, 255, 255))
		Speaker:SetExtraData('ChatColor', Color3.fromRGB(0, 226, 226))
		Speaker:SetExtraData('Tags', {{TagText = 'đź‘‘VIP', TagColor = Color3.fromRGB(0, 1, 1)}})
	end
end)
1 Like

Did you try it again after these changes?

Not right now, no. I’m currently in school right now, so I am unable to test it.

I edited the script when you told me what the error was, so hopefully it works now.

I can test it later, but that will take another hour before I could.

TL;DR I can’t test because I’m in Math Class.