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

Developer Product was working, now it doesn't?

Asked by 8 years ago

It will let someone purchase both 1,000,000 cash and 10,000,000 cash, however, only the 10,000,000 will get added. The 1,000,000 will not work. This is extremely confusing.

Here's the script:

local MarketplaceService = game:GetService('MarketplaceService')
local devproductid = 32819350 -- 10,000,000 Cash
local devproductid2 = 32819339

MarketplaceService.ProcessReceipt = function(receiptInfo)
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == devproductid then

            player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 10000000
            end
            elseif receiptInfo.ProductId == devproductid2
            then
            player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1000000
        end

    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end
0
You can merge the two script pretty easily. Just put and elseif on line 10 then "receiptInfo.ProductId == devProductId2" or something like that GoldenPhysics 474 — 8y
0
I joined both of them together and it's still not working with the 1,000,000 purchase. Tradesmark 65 — 8y
0
Are you sure you got the ID right? GoldenPhysics 474 — 8y
0
Positive. Tradesmark 65 — 8y
0
I've noticed in servers that it tends to work on one or the other. Never both. Tradesmark 65 — 8y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

You ended the if statement that was comparing the developer product ids!

local MarketplaceService = game:GetService('MarketplaceService')
local devproductid = 32819350 -- 10,000,000 Cash
local devproductid2 = 32819339

MarketplaceService.ProcessReceipt = function(receiptInfo)
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == devproductid then
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 10000000
            elseif receiptInfo.ProductId == devproductid2 then
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1000000
            end
        end
    end -- You were also missing one end.
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

Ad

Answer this question