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

Why wont this work? Please help!

Asked by 10 years ago
id = 20518668 --dev product id

script.Parent.MouseButton1Click:connect(function(p)
    game:GetService("MarketplaceService"):PromptProductPurchase(p, id)
    local MarketplaceService = Game:GetService("MarketplaceService")
    local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
    MarketplaceService.ProcessReceipt = function(receiptInfo) 
        if p.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == id then
                p.leaderstats.Cash.Value = p.leaderstats.Cash.Value + 5000
            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)

0
What error do you get? Try F9 in online mode, then go into Server Console. M39a9am3R 3210 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local link = game:GetService("MarketplaceService")
deb = 0


script.Parent.MouseButton1Click:connect(function()
local marketId = 0 --ID OF YOUR DEVELOPER PRODUCT  
link:PromptProductPurchase(plr,marketId)
link.ProcessReceipt = function(receiptInfo)
if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.PlayerId == plr.userId then
if deb == 0 then
deb = 1
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 1000 --Alter what stat you would like to increase or decrease after the player has purchased.
wait(1)
deb = 0
end
end
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)


put it in a text button or image button

0
It is in a text button I click it and nothing shows up. Any ideas? TheImmuneNoobKiller 0 — 10y
0
did you put the ID of the product? DrChowderr 0 — 10y
Ad

Answer this question