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

Why my dev product doesn't work?

Asked by
deris88 146
9 years ago

So I tried to make one and it looks like it should work, but I ran test, spent 5 robux and I didin't get thing that I should get when I buy that product. Here is the script :

01local buyButton = script.Parent
02local productId = 33818042
03local mps = game:GetService("MarketplaceService")
04 
05function getPlayerById(id)
06for i,v in pairs(game.Players:GetPlayers()) do
07if v.userId == id then
08return v
09end
10end
11end
12 
13buyButton.MouseButton1Click:connect(function()
14mps:PromptProductPurchase(game.Players.LocalPlayer, productId)
15end)
View all 22 lines...

It seems like it should work but I didin't get my 100 gems. Help please.

2 answers

Log in to vote
0
Answered by 9 years ago

Not sure if this will work but it's worth a try!

01-- Try putting this script into StarterPack
02 
03local MarketplaceService = game:GetService("MarketplaceService")
04local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
05 
06GEMSID = 33818042
07 
08MarketplaceService.ProcessReceipt = function(receiptInfo)
09    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
10    local numberBought = ds:IncrementAsync(playerProductKey, 1)
11    for i,v in pairs (game.Players:GetChildren()) do
12        if v.userId == receiptInfo.PlayerId then
13            if receiptInfo.ProductId == GEMSID then
14 
15 
View all 27 lines...
Ad
Log in to vote
0
Answered by 9 years ago

A few things: If you want to get a player from their userId, use this function.

Your if statement on Line 19 should be all one line. It looks really confusing otherwise.

Put parentheses around your arguments, otherwise it again looks confusing and isn't really the proper way to do things.

Now, to answer your question: It looks like to me you forgot to put a GetChildren() when you tried to index the players class. I don't see else anything wrong with your code, but I recommend you use the method provided by ROBLOX above, and if you still don't get your gems, it most likely is something with your leader board.

Answer this question