Developer Product Info
Developer Products in roblox are essentially re-purchasable GamePasses. To make one do what you want, you have to use the ProcessReceipt Callback of MarketplaceService.
ProcessReceipt Info
The ProcessReceipt Callback takes in a function! You have to define a function to the ProcessReceipt for it to work. It acts similiar to an event, it's a listener.. for whenever a DeveloperProduct is purchased. But unlike an event, it is not redefinable. You cannot define multiple ProcessReceipts and expect it to work. If you redefine a ProcessReceipt then it will just be overwritten.
The function that you tie to ProcessReceipt should have one parameter, because ProcessReceipt returns a value.. which is inofficially known as 'receiptInfo'. The receiptInfo has all the information about the Purchase of said Developer Product in a dictionary.
What receiptInfo contains
PlayerId is the userId of the player that bought the Product
PlaceIdWherePurchased is the game ID of where the Product was bought, useful for universes.
PurchaseId is a unique identifier for the purchase which is used to prevent granting an item multiple times for one purchase
ProductId is the asset ID of whatever product was bought.. used if a game has multiple Products.
CurrencyType is the type of currency spent on the Product(Robux or Tix).
CurrencySpent is the amount of [CurrencyType] that was spent
Mostly, the only things that you will have to use are ProductId, to tell what product was bought, and PlayerId, to tell which player bought the Product.
How To Make A Working ProcessReceipt
You need to first.. find the player that bought the pass by iterating through all players and comparing receiptInfo.PlayerId.
Then, you need to see what product was bought by comparing receiptInfo.ProductId with a predefined ID.
After that, award said player with whatever you want.
And lastly, you must return Enum.ProductPurchaseDecision.PurchaseGranted, in order to gain any money from the purchase.
Code
local id = 0000000
local ms = game:GetService('MarketplaceService')
ms.ProcessReceipt = function(receiptInfo)
local plr
for i,v in pairs(game.Players:GetPlayers())
if v.userId == receiptInfo.PlayerId then
plr = v
end
end
if receiptInfo.ProductId == id then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
1 comment
I know you don't want links but they have the code right there on the Developer Product page on the wiki and you can also check out the sample place to get an example.