Advertisement
Sungmingamerpro13

Extra Life With Tool Field trip Z Style

Nov 24th, 2024 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.13 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.  
  6. local function processReceipt(receiptInfo)
  7.     -- Find the player who made the purchase in the server
  8.     local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
  9.     if player then
  10.         -- Output what product they bought
  11.         print(player.Name .. " just bought " .. receiptInfo.ProductId)
  12.         boughtLifeEvent:FireClient(player)
  13.        
  14.         -- IMPORTANT: Tell Roblox that the game successfully handled the purchase
  15.         return Enum.ProductPurchaseDecision.PurchaseGranted
  16.     end
  17. end
  18.  
  19. -- Set the callback (this can only be done once by one script on the server!)
  20. MarketplaceService.ProcessReceipt = processReceipt
  21.  
  22. reviveEvent.OnServerEvent:Connect(function(player)
  23.     player:LoadCharacter()
  24.     if player and (player.Backpack) then
  25.         player.Backpack:FindFirstChild("Bat"):Destroy()
  26.         game.ServerStorage.Crowbar:Clone().Parent = player.Backpack
  27.     end
  28. end)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement