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
9 years ago

Here's my code so far -

01ShekelsGiven = 100
02 
03ProductID = 31831485
04 
05game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
06 
07    for i, player in ipairs(game.Players:GetChildren()) do
08 
09        if player.userId == receiptInfo.PlayerId then
10 
11            if receiptInfo.ProductId == ProductID then
12 
13                if receiptInfo.CurrencyType == Enum.CurrencyType.Robux then
14 
15                    player.ShopValues.Shekels.Value = player.ShopValues.Shekels.Value + ShekelsGiven
View all 27 lines...

Thanks for reading.

1 answer

Log in to vote
1
Answered by 9 years ago

You would do this:

01local ShekelsGiven = 100
02game:GetService("MarketplaceService").ProcessReceipt = function (receiptInfo)
03for i, player in ipairs(game.Players:GetChildren()) do
04 
05        if player.userId == receiptInfo.PlayerId then
06 
07 
08            -- check which product was purchased
09            if receiptInfo.ProductId == productId then
10 
11if receiptInfo.CurrencyType == Enum.CurrencyType.Robux then
12           player. leaderstats.Shekels.Value = player. Leaderstats.Shekels.Value + ShekelsGiven
13 
14end
15end
16end
17end
18return Enum.ProductPurchaseDecision.PurchaseGranted
19end)

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 — 9y
Ad

Answer this question