So in my game with dev products. I have 2 dev products. One gives 100k and other gives 500 k currency. But the problem is that, if I choose one to buy first, then buy a second one that's different, it will give the amount of currency equal to the one I bought first. If I buy the one I brought first again, it will give double the amount plz help!

DevProduct1 Local Script

local id = 455366694 

local mps = game:GetService("MarketplaceService")
plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	mps:PromptProductPurchase(plr,id)
end)

DevProduct1 Script

local mps = game:GetService("MarketplaceService")
local id = 455366694 
local amountGiven = 100000

mps.ProcessReceipt = function(receiptInfo)
	for i,player in pairs(game.Players:GetPlayers()) do
		if player.UserId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == id then
				local leaderstats = player:WaitForChild('leaderstats')
				if leaderstats then
					local boost = leaderstats:WaitForChild('Boost')
					if boost then
						print(boost.Value)
						print(amountGiven)
						print(boost.Value + amountGiven)
						boost.Value = boost.Value + amountGiven
					end
				end
			end
		end
	end
end

DevProduct2 Local Script

local id = 455367058 

local player = game.Players.LocalPlayer
local mps = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function()
	mps:PromptProductPurchase(player,id)
end)

DevProduct2 Script

local mps = game:GetService("MarketplaceService")
local id = 455367058 
local amountGiven = 500000

mps.ProcessReceipt = function(receiptInfo)
	for i,player in pairs(game.Players:GetPlayers()) do
		if player.UserId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == id then
				local leaderstats = player:WaitForChild('leaderstats')
				if leaderstats then
					local boost = leaderstats:WaitForChild('Boost')
					if boost then
						print(boost.Value)
						print(amountGiven)
						print(boost.Value + amountGiven)
						boost.Value = boost.Value + amountGiven
					end
				end
			end
		end
	end
end

2 comments

0

one word "debounce"

0

Are these are all separate scripts / localscripts?