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

Why doesn't my value increase when someone purchases?

Asked by
JipSea 23
4 years ago

Hello!

I am trying to get my leaderstat "Purchases" to increase when a player buys something in my store:

local mpService = game.getService("MarketplaceService")

mpService.ProcessReceipt = function(purchaseInfo)
    local plr = game.getService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId)
    if purchaseInfo.ITEM_ID == 123456 then
        --The value that will be incremented
        local Purchases = plr.leaderstats.Purchases;
        Purchases.Value = Purchases.Value +1
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

I put 123456 as a placeholder, but it would be the actual ID of the clothing item being purchased.

Any help would be appreciated, TY

0
Any ideas? JipSea 23 — 4y

1 answer

Log in to vote
0
Answered by
skyaz1 72
4 years ago

Just a syntax error on line 4, you used "game.getService", you have to use "game:GetService"

local plr = game:GetService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId) -- fixed line 4 
0
THANK YOU! OMG! LOL JipSea 23 — 4y
0
script may not be completely fixed tho skyaz1 72 — 4y
Ad

Answer this question