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

Tool Dev Product?

Asked by 9 years ago

I am trying to make a Developer Product give a tool after the player purchase's it,

-- setup local variables
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 19181612

game.Players.PlayerAdded:connect(function()
    print("start")
local DeveloperProducts = game:GetService("MarketplaceService"):GetDeveloperProductsAsync():GetCurrentPage()
for _, DevProductContainer in pairs(DeveloperProducts) do
    for Field, Value in pairs(DevProductContainer) do
        print(Field .. ": " .. Value)
    end
    print(" ")
end
print("end")
end)

-- 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. In this case we are healing the player.
                game.Lighting["Tool"]:clone().Parent = player.BackPack
                -- more feedback for the player.
                game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased a healing potion."
            end
        end
    end 

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

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

Anyone know why this won't work??

0
What do you mean by "won't work"? What are the errors? What behavior does work, what doesn't? What have you tried in debuggin? What were the results? BlueTaslem 18071 — 9y
0
It won't give the character the tool. InfinitivePixelsJr 542 — 9y

1 answer

Log in to vote
0
Answered by
Relatch 550 Moderation Voter
9 years ago

On line 30, you made 2 mistakes. But it's mainly the capitalization. To fix this, you need to change clone() to Clone(). Second, you need to change BackPack to Backpack.

game.Lighting["Tool"]:Clone().Parent = player.Backpack
--This is the fixed line (line 30). Change line 30 to this.
0
Thank's. InfinitivePixelsJr 542 — 9y
Ad

Answer this question