I see the print("") below being repeated multiple times in ServerLog when in PlayMode....shouldn't it only be running when a script runs
game:GetService('MarketplaceService'):PromptProductPurchase(game.Players.LocalPlayer, devid)
This is the script that keeps running over and over multiple times, I think that is why instead of getting 50 points added to my leaderboards, I get a very large number (as it is running multiple times)
MarketplaceService = game:GetService("MarketplaceService")
local DataStore = game:GetService("DataStoreService"):GetDataStore("mydatastore")
local devid = HIDDEN
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, v in pairs(game.Players:GetChildren()) do
if v.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == devid then
local oldValue = v.leaderstats.Coins.Value
DataStore:UpdateAsync(v.userId, function(oldValue)
v.leaderstats.Coins.Value = v.leaderstats.Coins.Value + 50 or 0
print("Gave player +50 Coins")
return v.leaderstats.Coins.Value + 50 or 0
end)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
end
Would adding an else statement work?
