CCCPaste

Extra Life With Tool Field trip Z Style

-- This code should be in a 'Script' object within 'ServerScriptService'
local MarketplaceService = game:GetService("MarketplaceService")
local boughtLifeEvent = game.ReplicatedStorage.DiedEvents.boughtLifeEvent
local reviveEvent = game.ReplicatedStorage.DiedEvents.reviveEvent
 
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

reviveEvent.OnServerEvent:Connect(function(player)
	player:LoadCharacter()
	if player and (player.Backpack) then
		player.Backpack:FindFirstChild("Bat"):Destroy()
		game.ServerStorage.Crowbar:Clone().Parent = player.Backpack
	end
end)