Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Working purchase, but no change on the Leaderboard?

Asked by 11 years ago

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.

1mps.ProcessReceipt = function(info)
2local plr = tonumber(getPlayerById(info.PlayerId))
3if plr and plr:FindFirstChild "leaderstats" and plr.leaderstats:FindFirstChild "Coins" then
4plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 5
5end
6end

Here is a full script.

01local buyButton = script.Parent
02local productId = 19187415
03local mps = game:GetService"MarketplaceService"
04 
05function getPlayerById(id)
06for i,v in pairs(game.Players:GetPlayers()) do
07if v.userId == id then
08return v
09end
10end
11end
12 
13buyButton.MouseButton1Click:connect(function()
14mps:PromptProductPurchase(game.Players.LocalPlayer, productId)
15end)
View all 22 lines...
0
You should check to make sure the productId's match, and if they do THEN award the stats. Also your "plr" is just the Player'sID not the actual player. jav2612 180 — 11y
0
You also need to use Enum.ProductPurchaseDecision.PurchaseGranted jav2612 180 — 11y

2 answers

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
11 years ago

developer products are very annoying, i got'it fixed after around 15 tries, here's the script ;)

01local MarketplaceService = game:GetService("MarketplaceService")
02local ProductID = DEVELOPER PRODUCT ID HERE
03 
04 
05MarketplaceService.ProcessReceipt = function(receiptInfo)
06 
07    for i, player in ipairs(game.Players:GetChildren()) do
08        if player.userId == receiptInfo.PlayerId then
09 
10 
11if receiptInfo.ProductId == ProductID then
12 
13--Do stuff here
14 
15            end
View all 21 lines...
0
I will try this script, if it works - I will mark it as an answer! BenHall4433 0 — 11y
0
I doesn't work! BenHall4433 0 — 11y
Ad
Log in to vote
0
Answered by 11 years ago

What about this? I tried the script above, but it doesn't work! Does this part of the script that needs changing?

Script Line:

01buyButton.MouseButton1Click:connect(function()
02mps:PromptProductPurchase(game.Players.LocalPlayer, productId)
03end)
04 
05mps.ProcessReceipt = function(info)
06local plr = tonumber(getPlayerById(info.PlayerId))
07if plr and plr:FindFirstChild "leaderstats" and plr.leaderstats:FindFirstChild "Coins" then
08plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 5
09end
10end

Answer this question