Okay, i’ve searched up many phrases on this topic and have read the offical roblox article on how this works… but i’m very lost here. This is what i’ve been able to write:
local ProximityPrompt = script.Parent
local DeveloperProductID = 1828395500
local MarketPlaceService = game:GetService("MarketplaceService")
ProximityPrompt.Triggered:Connect(function(player)
MarketPlaceService:PromptProductPurchase(player, DeveloperProductID)
-- uhh.. what do i write here?
end)
ProcessReceipt seems REALLY confusing to me and would like if someone were to provide an example of it’s usage. Thanks for reading!
ProcessReceipt is a callback, so if you want to use it you’ll need to do this:
local MPS = game:GetService("MarketplaceService")
local function processReceipt(info)
local plr = game.Players:GetPlayerByUserId(info.PlayerId)
if not plr then return Enum.ProductPurchaseDecision.NotProcessedYet end
-- your code here
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MPS.ProcessReceipt = processReceipt
Something very important to understand for starters is that only one function can be attached to this.
Having more than one script attach a function will cause random behaviour where only one function (the last one assigned) will be executed. You need one function to handle all products, but you can do this in multiple ways.
You also need to make sure to mark it as processed (after giving the product to the user) and save the receipt to mark it as processed again in case the function will be called again.