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

Why isn't my purchase script adding to leaderstats?

Asked by
JipSea 23
4 years ago

Hello!

I have re-written my script a bit and am still have issues w/it working. I am trying to add +1 to the customers leaderstat any time they purchase a clothing item from my home store, I have this as a server script:

local mps = game:GetService("MarketplaceService")

mps.ProcessReceipt = function(receiptInfo)
   local Player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
   if receiptInfo.ProductId == 1234546 then
        Player.leaderstats.Purchases.Value = Player.leaderstats.Purchases.Value + 1
        return Enum.ProductPurchaseDecision.PurchaseGranted
   elseif receiptInfo.ProductId == 12345467 then
        Player.leaderstats.Purchases.Value = Player.leaderstats.Purchases.Value + 1
        return Enum.ProductPurchaseDecision.PurchaseGranted

   end
end

I used "123456" and "1234567" as placeholders, I would put the actual ID of the item there in game.

I have a basic leaderstat script:

game.Players.PlayerAdded:Connect(function(plr)
    local Stats = Instance.new('Folder') 
    Stats.Name = 'leaderstats'
    Stats.Parent = plr

    local Purchases = Instance.new('IntValue')
    Purchases.Name = 'Purchases'
    Purchases.Value = 0
    Purchases.Parent = Stats


end)

Any suggestions or thoughts as to why this is not working?

0
ProcessReceipt only works with Developer Products. y3_th 176 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Hello!

Like the two people above me said, ProcessReceipt works with Developer Products, not clothing. Do you have an example code from when you're selling the clothing? I'm guessing it would look similar to this:

local sell = script.Parent
local Item = 4825559312 --ID of product

local Click = Instance.new("ClickDetector",sell)

Click.MouseClick:connect(function(p)
    game:GetService("MarketplaceService"):PromptPurchase(p,item)
end)

Check out this page! :)

https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/PlayerOwnsAsset

Hope this helps

Ad
Log in to vote
0
Answered by 4 years ago

ProcessReceipt only works with Developer Products.

Answer this question