I made a developer product system. For some reason, if the player has more than 0 Treasure, it all the products give more Treasure than they are supposed to. Here's the code.
local marketplaceService = game:GetService("MarketplaceService")
local productID = 305518579 --100 Treasure
local productID2 = 305551012 --500 Treasure
local productID3 = 305580165 --1000 Treasure
local productID4 = 305663788 --2500 Treasure
local productID5 = 305667113 --5000 Treasure
marketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == productID then
local treasure = player.leaderstats.Treasure
local totalTreasure = player.TotalTreasure
treasure.Value = treasure.Value + 100
totalTreasure.Value = player.TotalTreasure.Value + 100
end
if receiptInfo.ProductId == productID2 then
local treasure = player.leaderstats.Treasure
local totalTreasure = player.TotalTreasure
treasure.Value = treasure.Value + 500
totalTreasure.Value = totalTreasure.Value + 500
end
if receiptInfo.ProductId == productID3 then
local treasure = player.leaderstats.Treasure
local totalTreasure = player.TotalTreasure
treasure.Value = treasure.Value + 1000
totalTreasure.Value = totalTreasure.Value + 1000
end
if receiptInfo.ProductId == productID4 then
local treasure = player.leaderstats.Treasure
local totalTreasure = player.TotalTreasure
treasure.Value = treasure.Value + 2500
totalTreasure.Value = totalTreasure.Value + 2500
end
if receiptInfo.ProductId == productID5 then
local treasure = player.leaderstats.Treasure
local totalTreasure = player.TotalTreasure
treasure.Value = treasure.Value + 5000
totalTreasure.Value = totalTreasure.Value + 5000
end
end
end
end

1 comment
So what do i use instead?