Sungmingamerpro13

processReceiptScript

Oct 9th, 2026
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.82 KB | None | 0 0
  1. -- This code should be in a 'Script' object within 'ServerScriptService'
  2. local MarketplaceService = game:GetService("MarketplaceService")
  3. local boughtLifeEvent = game.ReplicatedStorage.DiedEvents.boughtLifeEvent
  4.  
  5. local function processReceipt(receiptInfo)
  6.     -- Find the player who made the purchase in the server
  7.     local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
  8.     if player then
  9.         -- Output what product they bought
  10.         print(player.Name .. " just bought " .. receiptInfo.ProductId)
  11.         boughtLifeEvent:FireClient(player)
  12.        
  13.         -- IMPORTANT: Tell Roblox that the game successfully handled the purchase
  14.         return Enum.ProductPurchaseDecision.PurchaseGranted
  15.     end
  16. end
  17.  
  18. -- Set the callback (this can only be done once by one script on the server!)
  19. MarketplaceService.ProcessReceipt = processReceipt
  20.  
Advertisement
Add Comment
Please, Sign In to add comment