Process Receipt Duplication Issue

I have quite an annoying issue, I don’t know if it’s related to the process receipt that this script is inside of, I’ve provided a segment of the script inside of my process receipt below;

	if receiptInfo.ProductId == gemsID then
		if player:FindFirstChild("Potions") and player.Potions["GemsBoostActive?"].Value == false then -- Check if Potions exists before accessing its child
			local potionGUI = ReplicatedStorage:FindFirstChild("GemsPotion"):Clone()
			if potionGUI then
				potionGUI.Parent = player.PlayerGui:WaitForChild("UserUI"):WaitForChild("PotionFrame")
			else
				warn("GemsPotion not found in ReplicatedStorage")
			end
			player.Potions["GemsBoostActive?"].Value = true
		end
		player.Potions["GemsBoostTime"].Value = player.Potions.GemsBoostTime.Value + 30 * 60 

	elseif receiptInfo.ProductId == winsID then
		if player:FindFirstChild("Potions") and player.Potions["WinsBoostActive?"].Value == false then 
			local potionGUI = ReplicatedStorage:FindFirstChild("WinsPotion"):Clone()
			if potionGUI then
				potionGUI.Parent = player.PlayerGui:WaitForChild("UserUI"):WaitForChild("PotionFrame")
			else
				warn("WinsPotion not found in ReplicatedStorage")
			end
			player.Potions["WinsBoostActive?"].Value = true
		end
		player.Potions["WinsBoostTime"].Value = player.Potions.WinsBoostTime.Value + 30 * 60 

The issue simply is that whenever the product is purchased, the first time the functionality works fine, it’s expected to add 1800 (30 * 60) to the players WinsBoostTime.Value. When the product is purchased for a second timer, however, it duplicates itself and then adds 3600, then it keeps doubling itself every purchase. Any insight on this issue would be greatly appreciated, thanks alot.

Bump, still need help with this

Is the code being called more times than you expect? Based on what you’ve shown, I don’t see why it would be doubling after each purchase.

Maybe, is it possible that the ProcessReciept is being called multiple times?

Are you ever returning Enum.ProductPurchaseDecision.PurchaseGranted in your processreceipt function? You need to do that, processreceipt will be called repeatedly until it is returned

2 Likes

Hey there, thanks so much. I didn’t even realize I was skipping out on returning Enum.ProductPurchaseDecision.PurchaseGranted. This worked, thanks alot for pointing it out. :woot:

1 Like

The documentation is consistent with what @7z99 said: MarketplaceService | Documentation - Roblox Creator Hub

Unresolved developer product purchases are not removed or refunded after the escrow period has expired. Instead, ProcessReceipt callbacks will indefinitely be invoked for unresolved purchases in the manner described above.

1 Like

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