I tried to increase a value in a player's leaderstats by 1,000 every time they purchase a developer product, but it keeps multiplying 1,000 by the number of times the product was purchased. (Example: First time buying I would get 1,000, but next time I would get 2,000 instead of 1,000) I expected the script to add 1,000 every time. Here is my ProcessReceipt script (located in ServerScriptService):
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local mainDataStore = DataStoreService:GetDataStore("MainData")
local function processReceipt(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == 1018802173 then
player.leaderstats.Coins.Value += 1000
mainDataStore:SetAsync("Coins_" .. receiptInfo.PlayerId, player.leaderstats.Coins.Value)
ReplicatedStorage.SendClientMessage:FireClient(player, "The game has been saved!")
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
There are no errors on the server or the client, and I tested on Roblox Studio instead of a live Roblox server so I could use test purchases.

4 comments
Hello, I have a question how this works... Sorry I don't get it why do you have to add 2,000 if the player bought the product more than once?
Ahh you can multiply the amount of coins they get by how many boughts they have
If this works please accept the answer
No that's not what I meant, I mean this was happening and I only wanted it to add 1,000 but it randomly solved itself so it's ok