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

Some Dev Products are not working and others are?

Asked by 6 years ago

Hello! So I used the code provided from the wiki to create multiple dev products but for whatever reason, in-game, not all of them give out the cash when purchased? Below is the code that I used under all three text boxes that are clicked to be purchased. They are all the same except for the IDs and the money given.

local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 109874232 --Change to dev product ID

MarketplaceService.ProcessReceipt = function(receiptInfo) 

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

            if receiptInfo.ProductId == productId then

                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 50000 --Change to Cash added when bought
            end
        end
    end 

    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId
    ds:IncrementAsync(playerProductKey, 1)  

    return Enum.ProductPurchaseDecision.PurchaseGranted     
end
--LocalScript in StarterPack
-- setup local variables
local buyButton = script.Parent
local productId = 109874232

-- when player clicks on buy brick prompt him/her to buy a product
buyButton.MouseButton1Click:connect(function()
    game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

Answer this question