Developer Product Sending Multiple Requests

I made a system where if you purchase a developer product, it updates an intvalue in a players leaderstats. When I purchase it the first time it works as expected, but when I try again it adds double the amount it’s supposed to.

Button Code:

local button = script.Parent
local id = 1527475121
local MPS = game:GetService("MarketplaceService")
local player = game:GetService("Players").LocalPlayer
local event = game.ReplicatedStorage.RemoteEvents.addCoins
local amount = 25
local deobunce = false

button.MouseButton1Click:Connect(function()
	if not deobunce then
		deobunce = true
		MPS:PromptProductPurchase(player, id)
		task.wait(1)
		deobunce = false
	end
end)

Handler Code:

local MPS = game:GetService("MarketplaceService")
local ids = {
	1527474667,
	1527474899,
	1527475121
}
local event = game.ReplicatedStorage.bindableEvents.addCoins

local function processReceipt(receiptInfo)
	local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	local id
	if player then
		if receiptInfo.ProductId == ids[1] then
			event:Fire(player, 25)
		elseif receiptInfo.ProductId == ids[2] then
			event:Fire(player, 50)
		elseif receiptInfo.ProductId == ids[3] then
			event:Fire(player, 100)
		end
	end
end

MPS.ProcessReceipt = processReceipt

Leaderstats Code:

event3.Event:Connect(function(player, amount)
	player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + amount
end)

It looks like the issue is likely due to the fact that the button code is calling PromptProductPurchase() from MarketplaceService each time the button is clicked, rather than letting the player purchase the product only once. After the player purchases the product once, further clicks on the button will still call the function, which will result in the player being charged again and the intvalue in their leaderstats being updated with another amount.

One possible solution would be to add a check to see if the player has already purchased the product before allowing them to purchase it again. This could be done by storing a boolean value in the player’s PlayerData folder (or some other location), which is set to true after the first purchase and prevents further purchases from being made until it is reset.

Another solution would be to modify the code to use a different approach, such as creating a gamepass or using a DataStore to track a player’s purchase history and avoid calling PromptProductPurchase() multiple times.