Advertisement
Sungmingamerpro13

ProcessReceiptScript (Break In Style)

Jan 13th, 2025
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.58 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. local reviveEvent = game.ReplicatedStorage.DiedEvents.reviveEvent
  5. local reviveEvent2 = game.ReplicatedStorage.DiedEvents.reviveEvent2
  6.  
  7. local RoleItems = game.ServerStorage.SavedTools
  8.  
  9. local function processReceipt(receiptInfo)
  10.     -- Find the player who made the purchase in the server
  11.     local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
  12.     if player then
  13.         -- Output what product they bought
  14.         boughtLifeEvent:FireClient(player)
  15.  
  16.  
  17.         -- IMPORTANT: Tell Roblox that the game successfully handled the purchase
  18.         return Enum.ProductPurchaseDecision.PurchaseGranted
  19.     end
  20. end
  21.  
  22. -- Set the callback (this can only be done once by one script on the server!)
  23. MarketplaceService.ProcessReceipt = processReceipt
  24.  
  25. reviveEvent.OnServerEvent:Connect(function(player)
  26.     player:LoadCharacter()
  27.     if (player) and (player.Backpack) then
  28.         for _, Item in pairs(player.Backpack:GetChildren()) do
  29.             if Item:IsA("Tool") then
  30.                 Item:Destroy()
  31.             end
  32.         end
  33.     end
  34.     RoleItems.Bat:Clone().Parent = player.Backpack
  35. end)
  36.  
  37. reviveEvent2.OnServerEvent:Connect(function(player)
  38.     player:LoadCharacter()
  39.     if (player) and (player.Backpack) then
  40.         for _, Item in pairs(player.Backpack:GetChildren()) do
  41.             if Item:IsA("Tool") then
  42.                 Item:Destroy()
  43.             end
  44.         end
  45.     end
  46.     RoleItems.Bat:Clone().Parent = player.Backpack
  47.     RoleItems.Medkit:Clone().Parent = player.Backpack
  48. end)
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement