Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't my value increase when someone purchases?

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

1 comment

0

Any ideas?

1 answer

✓ Accepted answer

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 

2 comments

0

THANK YOU! OMG! LOL

0

script may not be completely fixed tho

This discussion is preserved as it was. New answers, comments, and votes are closed.