Advertisement
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 reviveEvent2 = game.ReplicatedStorage.DiedEvents.reviveEvent2
- local reviveEvent3 = game.ReplicatedStorage.DiedEvents.reviveEvent3
- local RoleItems = game.ServerStorage.RoleItems
- 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
- reviveEvent2.OnServerEvent:Connect(function(player)
- player:LoadCharacter()
- if (player) and (player.Backpack) then
- for _, Item in pairs(player.Backpack:GetChildren()) do
- if Item:IsA("Tool") then
- Item:Destroy()
- end
- end
- end
- RoleItems.Bat:Clone().Parent = player.Backpack
- RoleItems.Medkit:Clone().Parent = player.Backpack
- end)
- reviveEvent3.OnServerEvent:Connect(function(player)
- player:LoadCharacter()
- if (player) and (player.Backpack) then
- for _, Item in pairs(player.Backpack:GetChildren()) do
- if Item:IsA("Tool") then
- Item:Destroy()
- end
- end
- end
- RoleItems.Bat:Clone().Parent = player.Backpack
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement