Working purchase, but no change on the Leaderboard?
Hello, I am having problem with Developer Product - the purchase pop-up does work and completed, but the problem I am having that the Leaderboard is not changing it's value.
Another words: The purchase thing works - just that the Leaderboard doesn't update the Coins after purchase.
Can anyone help me with the scripting???
Here is the part of the script that doesn't work.
1 | mps.ProcessReceipt = function (info) |
2 | local plr = tonumber (getPlayerById(info.PlayerId)) |
3 | if plr and plr:FindFirstChild "leaderstats" and plr.leaderstats:FindFirstChild "Coins" then |
4 | plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 5 |
Here is a full script.
01 | local buyButton = script.Parent |
02 | local productId = 19187415 |
03 | local mps = game:GetService "MarketplaceService" |
05 | function getPlayerById(id) |
06 | for i,v in pairs (game.Players:GetPlayers()) do |
13 | buyButton.MouseButton 1 Click:connect( function () |
14 | mps:PromptProductPurchase(game.Players.LocalPlayer, productId) |
17 | mps.ProcessReceipt = function (info) |
18 | local plr = tonumber (getPlayerById(info.PlayerId)) |
19 | if plr and plr:FindFirstChild "leaderstats" and plr.leaderstats:FindFirstChild "Coins" then |
20 | plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 5 |