Bug with VIP Chat tags

I need this to display a VIP chat tag, but it isn’t. I have several errors happening, and unsure what they mean, the one concerning me is

MarketPlace:UserOwnsGamePassAsync() can only query local player

Does anyone have a fix?

Code;


--the area where the VIP tags are checked, this is in a module in chat.
function sendInfo(player)
		local info = saves[player.UserId] 
	if not info then
		local priority = 0
		
			if HighRankList[player.userId] then
			info = CreateTable(player, HighRankList[player.UserId])
		elseif game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 6770843) then
			info = CreateTable(player, "VIP")
		end
		
		if info == nil then
			info = "placeholder"
		end	
	
		saves[player.UserId] = info 
		return info
	else
return info

Try using :UserOwnsGamePassAsync() in a pcall function because it’s bound to error.

local ownership

local success, errorMessage = pcall(function()
     ownership = game:GetService('MarketplaceService'):UserOwnsGamePassAsync()
end)

if success and ownership then
  -- do your code here
end  

1 Like

So like this?

local success, errorMessage = pcall(function()
     ownership = game:GetService('MarketplaceService'):UserOwnsGamePassAsync()
end)

if success and ownership then
function sendInfo(player)
		local info = saves[player.UserId] 
	if not info then
		local priority = 0
		
			if HighRankList[player.userId] then
			info = CreateTable(player, HighRankList[player.UserId])
		elseif game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 6770843) then
			info = CreateTable(player, "VIP")
		end
		
		if info == nil then
			info = "placeholder"
		end	
	
		saves[player.UserId] = info 
		return info
		end  

That’s not going to work because that would only run once and there is no player to check if they have ownership. It needs to be inside the function. ( I also fixed up your indentation and cleaned up the code )

(Note: there’s nothing that checks if they are both in the HighRankList and own the gamepass. What if they are a high rank but they own the gamepass. Wouldn’t you want them to own both tags? Or does your functionality only want one important tag?)

local marketplaceService = game:GetService('MarketplaceService')

function sendInfo(player)
	local info = saves[player.UserId] 
	if not info then
		local priority = 0
		
		local ownership
		
		local success, message = pcall(function()
			ownership = marketplaceService:UserOwnsGamePassAsync(player.UserId, 6770843)
		end)
		
		if HighRankList[player.userId] then
			info = CreateTable(player, HighRankList[player.UserId])
		elseif ownership then
			info = CreateTable(player, "VIP")
		end
		
		if info == nil then
			info = "placeholder"
		end	
	
		saves[player.UserId] = info 
		return info
	else
		return info
	end
end
1 Like

This worked in studio, and if there is one player in the server. If several users with VIP join, this breaks, and doesn’t even display a normal tag. There is no error, what do you think the issue is?

Pretty sure the tags are broken , this still isn’t the solution.

I honestly do not know because you haven’t provided information on what the other functions do. Are you sure the player parameter is correct? Since the error says it can only query the local player, try sending in the local player? I’m not entirely sure because I’ve never seen that error before.

I’ve made chat tags work with gamepasses before and I can look into your place file if you wouldn’t mind (make a separate place with the chat system).