Here is my developer product code:
local fiveId = 30947986 local tenId = 30948013 local twentyfiveId = 30948036 local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then local cash = player.leaderstats.Cash if receiptInfo.ProductId == fiveId then cash.Value = cash.Value + 5000 print(player.Name .. " purchased 5K.") elseif receiptInfo.ProductId == tenId then cash.Value = cash.Value + 10000 print(player.Name .. " purchased 10K.") elseif receiptInfo.ProductId == twentyfiveId then cash.Value = cash.Value + 25000 print(player.Name .. " purchased 25K.") end end end local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId PurchaseHistory:IncrementAsync(playerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted end
Right now when I buy a product it runs through the script multiple times. Buying the 5K might add 5000 to my cash one time but then buy it again and it might add 15000 or 20000.
I bought the 10k one and the output was: Player purchased 10K. Player purchased 10K. Player purchased 10K. Player purchased 10K. Player purchased 10K. Player purchased 25K.
Looks like it's working now, all I changed was:
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId
to
local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
since it was too long.