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

Selling Dev Products? [closed]

Asked by 10 years ago

Please do not repost your question after it has been closed.

Can you help me with selling Dev Products? I made my products I just need a script that sells them. I am using a GUI and am trying to sell player points.

here's a script that doesn't work:

local buyButton = script.Parent local productId = 20139068 local Plr = script.Parent.Parent

buyButton.MouseButton1Click:connect(function() Game:GetService("MarketplaceService"):PromptProductPurchase(Plr, productId) end)

local MarketplaceService = Game:GetService("MarketplaceService")

MarketplaceService.PromptProductPurchaseFinished:connect(function(userId, productId, isPurchased) if isPurchased then

end end)

Why isn't it working? D:

Marked as Duplicate by User#2

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

This would go in a regular script inside of the GUI Button. Make sure to read the comments. Only reason it can't be in a LocalScript is.. erm... Forgot. I remember reading it on the Wiki.

id = 20139068 --dev product id
p = script.Parent.Parent -- Make this lead to the Parent of StarterGui

script.Parent.MouseButton1Down:connect(function()
        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
                game:GetService("PointsService"):AwardPoints(p.userId, 1) --1 is the amount of playerpoints that are awarded
        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 do you mean lead to the parent of startergui? Blueguy195 0 — 10y
0
Make it lead to Game? Blueguy195 0 — 10y
0
Yes. Shawnyg 4330 — 10y
0
19:50:12.664 - Unable to cast value to Object 19:50:12.664 - Script 'Players.Player1.PlayerGui.Shop.Frame.Hund.Script', Line 4 19:50:12.665 - Stack End Blueguy195 0 — 10y
View all comments (5 more)
0
fixed Shawnyg 4330 — 10y
0
What was it? Blueguy195 0 — 10y
0
Well, on my connection line, I added the variable 'p' on accident and made ROBLOX read it a WHOLEEEE different way. Shawnyg 4330 — 10y
0
Omg thank you soo much. Blueguy195 0 — 10y
0
No problem. Help me out by accepting my answer! Shawnyg 4330 — 10y
Ad