Players Receiving Everything They bought Before When Buying Somthing

Every time a player buys a Developer Product, they receive everything they have boughten before

For example, a player buys a Grapple Hook and receives it, They then later decide to buy a Rocket Launcher and receives Both the Rocket Launcher And The Grapple Hook

Heres my script below

local MPS = game:GetService("MarketplaceService")

MPS.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == 1382520299 then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Data.Coins.Value = player.Data.Coins.Value +200
		return Enum.ProductPurchaseDecision.PurchaseGranted

	elseif receiptInfo.ProductId == 1382548193 then -- replace with your ID here
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Data.Coins.Value = player.Data.Coins.Value +500
		return Enum.ProductPurchaseDecision.PurchaseGranted
		
	elseif receiptInfo.ProductId == 1382548258 then -- replace with your ID here
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Data.Coins.Value = player.Data.Coins.Value +1000
		return Enum.ProductPurchaseDecision.PurchaseGranted
		
	elseif receiptInfo.ProductId == 1382548383 then -- replace with your ID here
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Data.Coins.Value = player.Data.Coins.Value +2500
		return Enum.ProductPurchaseDecision.PurchaseGranted
		
	elseif receiptInfo.ProductId == 1702550133 then -- replace with your ID here
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Data.Coins.Value = player.Data.Coins.Value +5000
		return Enum.ProductPurchaseDecision.PurchaseGranted
		
	elseif receiptInfo.ProductId == 1702576849 then -- replace with your ID here
		local Plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		local t2 = game.ServerStorage.Gears.hook:Clone()
		t2.Parent = Plr.StarterGear
		local st2 = game.ServerStorage.Gears.hook:Clone()
		st2.Parent = Plr.Backpack
		
	elseif receiptInfo.ProductId == 1702585912 then -- replace with your ID here
		local Plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		local t2 = game.ServerStorage.Gears.rocket:Clone()
		t2.Parent = Plr.StarterGear
		local st2 = game.ServerStorage.Gears.rocket:Clone()
		st2.Parent = Plr.Backpack
		
	elseif receiptInfo.ProductId == 1702585914 then -- replace with your ID here
		
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		
		workspace.SoundFX.Alert:Play()
		
		game.ReplicatedStorage.NotifyClient:FireAllClients(player.Name.." Has Summoned All Events!", Color3.new(0, 0.666667, 1))
		
	
		local function AllEvents()
		for i,v in pairs(game.ServerStorage.Events:GetChildren()) do
			wait()
			workspace.SoundFX.EventPing:Play()
			local Event = v:Clone()
			Event.Parent = workspace.EventScripts
			Event.Enabled = true

			game.ReplicatedStorage.NotifyClient:FireAllClients("Event: "..Event.Message.Value.." ⚠️", Color3.new(1, 0.701961, 0.223529))
			workspace.Lobby.EventMachine.Orb.Orb.BrickColor = BrickColor.new("Medium stone grey")

		end
		print("Finished")
		end
		
		AllEvents()
		
		
	end
end

1 Like

you forgot to do return Enum.ProductPurchaseDecision.PurchaseGranted in those elseif blocks

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.