Cash is adding up

In this script I’m attempting to have a developer product add the cash value by 1000. Although after purchasing it again, instead of it going from 1000 to 2000. It goes form 1000 to 3000. And when continuing to purchase it adds up even higher.

local MarketPlaceService = game:GetService("MarketplaceService")

local Cash = 1860163525

MarketPlaceService.ProcessReceipt = function(receiptInfo)
	local plr = players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not plr then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	if receiptInfo.ProductId == Cash then
		plr.leaderstats.Cash.Value += 1000
	end
end
2 Likes

First of all, you should move this topic to the “Help and Feedback Scripting Support” category if you are looking for scripting support.

Secondly, the reason it doubles after purchasing multiple times is because you are not returning a purchase result. After adding the player’s cash, add a return Enum.ProductPurchaseDecision.PurchaseGranted, and it should fix the issue.

2 Likes

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