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

How do I add a developer product that would give points to a player to my game?

Asked by
pwnd64 106
8 years ago

Here's my code so far -

ShekelsGiven = 100

ProductID = 31831485

game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)

    for i, player in ipairs(game.Players:GetChildren()) do

        if player.userId == receiptInfo.PlayerId then

            if receiptInfo.ProductId == ProductID then

                if receiptInfo.CurrencyType == Enum.CurrencyType.Robux then

                    player.ShopValues.Shekels.Value = player.ShopValues.Shekels.Value + ShekelsGiven

                end

            end

        end

    end

    return Enum.ProductPurchaseDecision.PurchaseGranted

end

Thanks for reading.

1 answer

Log in to vote
1
Answered by 8 years ago

You would do this:

local ShekelsGiven = 100
game:GetService("MarketplaceService").ProcessReceipt = function (receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do

        if player.userId == receiptInfo.PlayerId then


            -- check which product was purchased
            if receiptInfo.ProductId == productId then

if receiptInfo.CurrencyType == Enum.CurrencyType.Robux then
           player. leaderstats.Shekels.Value = player. Leaderstats.Shekels.Value + ShekelsGiven

end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end)

Change Shekels in leaderstats to whatever you have as the leaderstats value for storing the points. Place this code in a Server Script as only the server can process receipts.

0
hm, it doesn't work for some reason. I'll edit with what I have now. pwnd64 106 — 8y
Ad

Answer this question