This script is supposed to add 1000 gold to you're leaderstats when bought. It works except each time you buy it it gives you more. It is supposed to add 1000 only but every time you buy it it increase like this. 1st time: 1000 2nd: 2000 3rd:3000 4th:4000 etc. Why is it doing this.
-Full Script
--Script in BuyButton part -- setup local variables local MarketplaceService = game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = 92719865 -- define function that will be called when purchase finished MarketplaceService.ProcessReceipt = function(receiptInfo) -- find the player based on the PlayerId in receiptInfo for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then -- check which product was purchased if receiptInfo.ProductId == productId then -- handle purchase player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 1000 end end end -- record the transaction in a Data Store local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId ds:IncrementAsync(playerProductKey, 1) -- tell ROBLOX that we have successfully handled the transaction return Enum.ProductPurchaseDecision.PurchaseGranted end
try line 19 this might be the issue it seems like its adding 1000 to the value each time make it go from 1000 to 2000 and so on
~~~~~~~~~~~~~~~~~ player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 1000 ~~~~~~~~~~~~~~~~~