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 10 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.

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

Here is a full script.

local buyButton = script.Parent
local productId = 19187415
local mps = game:GetService"MarketplaceService"

function getPlayerById(id)
for i,v in pairs(game.Players:GetPlayers()) do
if v.userId == id then
return v
end
end
end

buyButton.MouseButton1Click:connect(function()
mps:PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

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

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 — 10y
0
You also need to use Enum.ProductPurchaseDecision.PurchaseGranted jav2612 180 — 10y

2 answers

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

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

local MarketplaceService = game:GetService("MarketplaceService")
local ProductID = DEVELOPER PRODUCT ID HERE


MarketplaceService.ProcessReceipt = function(receiptInfo) 

    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then


if receiptInfo.ProductId == ProductID then

--Do stuff here

            end
        end 
    end


    return Enum.ProductPurchaseDecision.PurchaseGranted     
end
0
I will try this script, if it works - I will mark it as an answer! BenHall4433 0 — 10y
0
I doesn't work! BenHall4433 0 — 10y
Ad
Log in to vote
0
Answered by 10 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:

buyButton.MouseButton1Click:connect(function()
mps:PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

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

Answer this question