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

How to correctly use Developer Products?

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

I've only had one problem with DP before, but other than that, they always worked fine. Now, I tried accessing it through a GUI, and that's where I go wrong. Here's the script:

script.Parent.MouseButton1Click:connect(function()
    p = script.Parent.Parent.Parent.Parent.Parent
    script.Parent.Parent.Visible = false 
    if p.Order.Value == true then
        id = 20869844
game:GetService("MarketplaceService"):PromptProductPurchase(p, id)
    print('passed.5')
    wait()
    print('past 1st')
        print('past 2nd')
        -- setup local variables
local MarketplaceService = game:GetService("MarketplaceService")
wait()
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo) 
        if p.userId == receiptInfo.PlayerId then -- Most likely this is the  line where it goes wrong.
            print('3') -- Never gets up to here
            if receiptInfo.ProductId == id then
                print('close')
                p.Order.Value = false
                print('dd')
        for i,v in pairs(p.Order:GetChildren()) do
            if v:IsA("BoolValue") then
            game.Lighting[v.Name]:clone().Parent = p.Backpack
            end
        end
        p.Order:ClearAllChildren()
                -- more feedback for the player.
        end
    end 

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

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

    end
    script.Parent.Parent.Parent:Destroy()
end)

I've used this same template for any DP I ever had and it worked fine. This is a Script in a TextButton that is in a ScreenGui located in the PlayerGui.

0
You need to access the DataStoreService through a script, not a localscript. FearMeIAmLag 1161 — 10y
0
What is the error iaz3 190 — 10y
0
This is a regular script. No error shows Shawnyg 4330 — 10y

Answer this question