Okay so I am trying to incorporate UpdateAsync into my game, trying to follow the wiki but I think I am doing it wrong. I want a player to get 50 coins added to their Coins leaderboard status when they purchase a devproduct. This is the code I have in ServerScriptService to check if the player has purchased the devproduct.
MarketplaceService = game:GetService("MarketplaceService")
local devid = IDHERE
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 key = "user_" .. v.userId
local DataStore = game:GetService("DataStoreService"):GetDataStore("muhcurrency")
DataStore:UpdateAsync(key, function(oldValue)
local newValue = oldValue or 0
newValue = v.leaderstats.Coins.Value + 50
return newValue
end)
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
I know I am doing something wrong, could someone point it out? Thank You!

2 comments
Thank you. I am aware IDHERE is not really supposed to be that, I just put that as like a place holder. I beleive you forgot an ) at the first end so it should be end) so I added that in there. I went into online mode and tested it out....for some odd reason it added 100 coins instead of 50...that is strange, no?
Hmmm, that did not seem to fix it sadly. I used to have GetDataStore instead of GetGlobalDataStore. I've noticed that when I joined the server now (I also updated the script that makes the leaderboards to use GetGlobalDataStore) and I noticed that I had 0 currency (when doing just GetDataStore I had more) and when I buy something now, nothing happens at all. Also when leaving the currency does not