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

Can someone help me out with Developer Products?

Asked by 10 years ago

Is there an actual tutorial, besides the wiki's, on Developer Products? I mean yeah the wiki has one, but I don't entirely understand it, and I would rather have a video tutorial. I searched some on You-tube, but there's no tutorial on this?

If there's a tutorial on DataStore, that would help too.

Thanks in advance.

1 answer

Log in to vote
3
Answered by
KAAK82 16
10 years ago

Insert the following Script into ServerScriptService:

local MarketplaceService = game:GetService("MarketplaceService")
local HealthID, PointsID = 19476978, 19535279 --ID's of ur DP's
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

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 (required, otherwise you'll award the wrong items if you're using more than one developer product)
            if receiptInfo.ProductId == HealthID then
                -- handle purchase. In this case we are healing the player.
                player.Character.Humanoid.Health = 100
            elseif receiptInfo.ProductId == PointsID then
                -- handle purchase. In this instance we're giving the player 1000 extra points. 
                player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1000
            end
        end 
    end
    -- record the transaction in a Data Store
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
    PurchaseHistory:IncrementAsync(playerProductKey, 1) 
    -- tell ROBLOX that we have successfully handled the transaction (required)
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

Insert the following Scripts into the 2 Buttons:

local productId = 19535279 -- change to ur developer product ID
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function() --DONT CHANGE THIS
    Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
local productId = 19476978 -- change to ur developer product ID
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function() --DONT CHANGE THIS
    Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
0
Spoonfed btw SuperSamyGamer 316 — 5y
Ad

Answer this question