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

How to use Developer Products properly?

Asked by 10 years ago

When me and my friends tested the Developer Products it says the product is not for sale

local MarketplaceService = Game:GetService("MarketplaceService")
local buyButton = script.Parent.TextButton
local productId = 000000000 -- I didn't show the real productId

buyButton.MouseButton1Click:connect(function()
    MarketplaceService:PromptProductPurchase(player, productId)
end)

I also tried to make a Developer Product that increases your money value by 2000

--Script in Starter Pack

local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton
local productId = 20518668

-- 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)


--Script in button

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 20518668

-- define function that will be called when purchase finished
MarketplaceService.ProcessReceipt = function(receiptInfo) 

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


            -- check which product was purchased
            if receiptInfo.ProductId == productId then

                -- handle purchase
                player.leaderstats.Money.Value = player.leaderstats.Money.Value + 2000
            end
        end
    end 

    -- record the transaction in a Data Store
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
    ds:IncrementAsync(playerProductKey, 1)  

    -- tell ROBLOX that we have successfully handled the transaction
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

1 answer

Log in to vote
-2
Answered by 10 years ago

You might of gotten a error from line 8 as the variable is described as productId but it is catching it as LproductId.

Is the script in the starterpack a local Script? If not, it would error due to it being a normal script and you may need to change it to a local Script. Those appear to be the only two things wrong that may need to be done to have it work.

0
I see it says LproductId spikeyajay123123 0 — 10y
0
I will try it spikeyajay123123 0 — 10y
Ad

Answer this question