I have NEVER worked with developer products in my entire life and I am so SO confused at what this script is doing. It is working with one ... issue ? I don't know because I don't know what it is doing. Read my notes and hopefully you are able to explain what is going on. :) Thanks!
-- setup local variables (I know this part)
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 36573978
-- define function that will be called when purchase finished
MarketplaceService.ProcessReceipt = function(receiptInfo) -- What does this do?
-- find the player based on the PlayerId in receiptInfo (sort of makes sense to me)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
-- check which product was purchased (again only sort of makes sense)
if receiptInfo.ProductId == productId then
-- handle purchase (I actually know what this does because I coded it so...)
player.leaderstats.Simoleons.Value = player.leaderstats.Simoleons.Value + 1000
print("success")
end
end
end
-- record the transaction in a Data Store (what...?)
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId
-- ds:IncrementAsync(playerProductKey, 1) -- I had to remove this line, after multiple buys you would get duplicate rewards. What does this line do? Is it important?
-- tell ROBLOX that we have successfully handled the transaction
return Enum.ProductPurchaseDecision.PurchaseGranted -- yeah no idea what this is doing
end
Thank you for your time. I am still really in the basics of Lua and things like this are just not pick apartable for me because I just do not understand what is going on.

3 comments
(This is based on my version of common sense, as I have never used dps as well.
When the ds:Increment thing was in the original code, every time I bought it multiple times it would give me first +1000 then +2000 then +3000 (so i end up with 6000 total) after removing it this was prevent and it adds correctly. Any ideas why? Accepted your answer though because it helped a lot :)
I'm a bit surprised and didn't know that was a thing. Must be an optional line for if you feel like you want/need it.