PromptProductPurchase running as many times previously purchased?

I’m working on a money developer product but I’ve run into an issue. Say you buy the dev product once, it’ll give you 1000 money. Buy it again? It gives 2000 money. A third time? 3000 money. Any ideas on how to fix this? I’m new to developer products and all the tutorials I’ve watched haven’t said anything about this being a problem.

Code:

local marketPlaceService = game:GetService("MarketplaceService")

function processReceipt(info)
	local player = game.Players:GetPlayerByUserId(info.PlayerId)
	if player then
		if info.ProductId == script.Parent.ID.Value then
			player.leaderstats.Money.Value = player.leaderstats.Money.Value + script.Parent.Money.Value
		end
	end
end

script.Parent.MouseButton1Click:Connect(function(clicked)
	marketPlaceService:PromptProductPurchase(player, script.Parent.ID.Value)	
end)

marketPlaceService.ProcessReceipt = processReceipt

Provide your code so we can understand why this is happening

Edited the code in. Sorry about that.

You never tell the game that the purchase was successful, somewhere in the ProcessReceipt callback you need to include return Enum.ProductPurchaseDecision.PurchaseGranted, preferably at the end, though you need to improve the callback code in the event something happens where you do not want to grant the purchase, such as the player leaving before granting the rewards,

I recommend reading up on this article to help you learn

2 Likes

This is why that happens:

@EmbatTheHybrid preceded me but she is right.

Well, thanks for the help! I put return Enum.ProductPurchaseDecision.PurchaseGranted and it works. I didn’t realize that was important.

1 Like