[SOLVED] Why does UserOwnsGamePassAsync return an error a lot of the time?

I have this code to check for a gamepass to give a gear:

local bubblegum = game.ServerStorage.Bubblegum



local gamePassID = 7750280


game.Players.PlayerAdded:Connect(function(player)
	
	local hasPass = false
 

	local success, message = pcall(function()
		hasPass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)
 

	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end
 
	if hasPass == true or player.UserId == 84182809 or player.UserId == 77108475 then
		print(player.Name .. " owns the game pass with ID " .. gamePassID)
		bubblegum:Clone().Parent = player.Backpack
		bubblegum:Clone().Parent = player.StarterGear
		
		local hatsFolder = Instance.new("Folder", game.ReplicatedStorage)
		
		hatsFolder.Name = "Hats" .. player.UserId
	end
	
end)

Most of the time, however, the output is:

GamePassId ‘7750280’ is not of type Game Pass. Please use MarketplaceService:PlayerOwnsAsset instead.

I’ve looked for how to use PlayerOwnsAsset for a while, yet still do not understand how it works so I am unable to implement it into my code.
I’d love for someone to explain how it works :smiley:

Here’s the gamepass: Kidanger Bubbblegum - Roblox

Could you post the link to the game pass?

1 Like

PlayerOwnsAsset is very similar to UserOwnsGamePassAsync, the only main difference is that it takes a player instead of their id.

To implement this, change UserOwnsGamePassAsync to PlayerOwnsAsset and make player.UserId into player like so:

hasPass = game:GetService("MarketplaceService"):PlayerOwnsAsset(player, gamePassID)

I do not know at all why it’s saying a GamePass is a asset nor how to fix it though.

5 Likes