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.
-- 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) -- Whenever you go to https://www.roblox.com/my/money.aspx#/#MyTransactions_tab it shows your receipts, which is a look at what you bought. --Makes sure that the player on the receipt is the player getting the rewards. for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then --Makes sure the product is the one that the player bought 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 --Records this in the datastore, which is a save system roblox has. local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId -- ds:IncrementAsync(playerProductKey, 1) --I'm pretty sure this line is important. It allows developer products to be purchased over and over again, which is the entire point of dps. If you didn't want this, there's always gamepasses. --This tells roblox that the purchase finished, the player had enough money, and it had no errors buying it. return Enum.ProductPurchaseDecision.PurchaseGranted end