Checking whose gamepass a player bought

I am currently trying to find a way to retrieve data about a gamepass/product bought by a player. I would like to award the gamepass/product owner a reward for successfully selling a gamepass of theirs.

The issue is that I can’t find the proper API/way to approach this.

I tried implementing the response from the https://api.roblox.com/marketplace/productinfo?assetId=1 API into MarketplaceSerice but that’s just giving me wrong info about the product/gamepass itself.

Hi,
Did you mean checking if a player has a certain gamepass or bought a gamepass/product in game?
If so then here’s the simple code.

local ms = game:GetService("MarketplaceService")

-- how to check if a player owns a gamepass 

ms:UserOwnsGamePassAsync("the player's UserId", "the gamepass id")

-- how to check if a player bought a gamepass

ms.PromptGamePassPurchaseFinished:Connect(function(PlayerWhoBoughtIt, GamepassId, WasPurchased)
	if WasPurchased then
		if GamepassId == the id of the gamepass then
			--do what you want
		end
	end
end)

--how to check if player bought a product

local function processReceipt(receiptInfo)
	local PlayerUserId = receiptInfo.PlayerId
	local player = game.Players:GetPlayerByUserId(PlayerUserId)
	
	local idBought = receiptInfo.ProductId
	

	
	if idBought == the product you want then
		--do your stuff
		
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
	
end

	

ms.ProcessReceipt = processReceipt

You can find more here: MarketplaceService.ProcessReceipt
And here: MarketplaceService:PromptGamePassPurchase

Hope I helped you ! :grinning:

2 Likes

That’s not really what I wanted :frowning:

I want to gain information about a gamepass/product and who is the seller of that gamepass/product. I am developing a donation game and I don’t really know how to get the info about every player’s gamepass/product that they are promoting.

Use MarketplaceService:GetProductInfo for this task. Simply provide it:

  • The AssetID

  • Enum.InfoType.GamePass or .Product or .Asset

and it will return a dictionary with info such as its name, description, price in robux, iconimage e.t.c

Oh yeah, I didn’t know about this function. Thanks a lot :slight_smile: