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

Trying to use a DevProduct to give a player Credits, what can I do to fix this script?

Asked by 8 years ago
01local MarketplaceService=game:GetService("MarketplaceService")
02local devproductid=52874408
03MarketplaceService.ProcessReceipt = function(receiptInfo)
04    for i,player in ipairs(game.Players:GetChildren()) do
05        if receiptInfo.ProductId == devproductid then
06        player.Credits.Value = player.Credits.Value + 100
07        end
08        end
09return Enum.ProductPurchaseDecision.PurchaseGranted
10    end

This is supposed to give 100 credits to the player, however, when tested in the actual game it doesn't give the player credits. It works in normal mode however

0
Heads up; You don't check the playerId, just the ProductId, wich means every player will get credits instead of the player that purchase it. RubenKan 3615 — 8y

1 answer

Log in to vote
1
Answered by
Nogalo 148
8 years ago

Here is a dev product script that you can use for any dev product you just have to change what should be done if all requirements are met. I've edited it to suit your needs so you can just copy and paste it but i do suggest you go through it and see what does what and why it's suppose to be that way

01local MarketplaceService = game:GetService("MarketplaceService")
02local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
03local productId = 52874408
04 
05 
06    MarketplaceService.ProcessReceipt = function(receiptInfo)
07 
08    for i, player in ipairs(game.Players:GetChildren()) do
09 
10        if player.userId == receiptInfo.PlayerId then
11 
12            if receiptInfo.ProductId == productId then
13 
14            player.Credits.Value = player.Credits.Value + 100
15            end
View all 23 lines...
Ad

Answer this question