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.
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
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.