PromptProductPurchaseFinished Help

game.ReplicatedStorage.BuyPoints.OnServerEvent:Connect(function(plr, value)
local gamepassservice = game:GetService("MarketplaceService")
gamepassservice:PromptProductPurchase(plr, 1040843938)
gamepassservice.PromptProductPurchaseFinished:Connect(function(...)
	local t = {...}	
	local h = t[3]
	wait(3)
	if h == true then
		plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + value
	end
end)
end)

This is my code and when ever this is fired the value added to my currency is being doubled.

First purchase will give me 100K cash and second purchase will give me 300K cash then third purchase will give 600K cash. How do I stop this?

This code will bind a purchase check function every time the remote event fires. To stop this issue you need to bind checking function only once. Also for DevProducts you should not use MarketplaceService.PromptProductPurchaseFinished. Instead use MarketplaceService.ProcessReceipt. This article may help you implement this.

1 Like