Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This code should be in a 'Script' object within 'ServerScriptService'
- local MarketplaceService = game:GetService("MarketplaceService")
- local boughtLifeEvent = game.ReplicatedStorage.DiedEvents.boughtLifeEvent
- local function processReceipt(receiptInfo)
- -- Find the player who made the purchase in the server
- local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
- if player then
- -- Output what product they bought
- print(player.Name .. " just bought " .. receiptInfo.ProductId)
- boughtLifeEvent:FireClient(player)
- -- IMPORTANT: Tell Roblox that the game successfully handled the purchase
- return Enum.ProductPurchaseDecision.PurchaseGranted
- end
- end
- -- Set the callback (this can only be done once by one script on the server!)
- MarketplaceService.ProcessReceipt = processReceipt
Advertisement
Add Comment
Please, Sign In to add comment