I've made a GUI where you can purchase coins, and it has multiple choices for the number of coins you want to buy and when the user picks the one he wants, let's say 500 coins, it will cost 10r$, I have that part down, but I cannot figure out how to process the transaction by adding 500 coins.
The script prompting the purchase:
local MPS = game:GetService("MarketplaceService") local PL = game:GetService("Players") local player = PL.LocalPlayer script.Parent.MouseButton1Click:connect(function() MPS:PromptProductPurchase(player, 429634850) end)
Instance a script into serverscriptservice and type in
When you purchased, you need to handle it on server script. Purchase grant can't be added automatically
You can read about product handling more here
local MarketplaceService = game:GetService("MarketplaceService") local function processReceipt(receiptInfo) -- Find the player who made the purchase in the server local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId) if not player then -- The player probably left the game -- If they come back, the callback will be called again return Enum.ProductPurchaseDecision.NotProcessedYet end -- Output what product they bought print(receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId) -- Tell Roblox that the game successfully handled the purchase return Enum.ProductPurchaseDecision.PurchaseGranted end MarketplaceService.ProcessReceipt = processReceipt