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

How to sell multi dev products?

Asked by 9 years ago

I made a gui shop for buy cash in game [TYCOON] I made 2 test "Buy 500 Cash" and " Buy 1000 Cash" The 1000 works the 500 not

This script going in my TextButtom from my gui; [1000 Cash]

local productId = 22197517 
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
    Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)

This script in starterpack;


local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") CASHID = 22197517 -- Put the Developer Product ID here MarketplaceService.ProcessReceipt = function(receiptInfo) local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId local numberBought = ds:IncrementAsync(playerProductKey, 11) for i,v in pairs (game.Players:GetChildren()) do if v.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == CASHID then lds = v:FindFirstChild("leaderstats") if lds ~= nil then cs = lds:FindFirstChild("Cash") --Change to your leaderstat if cs ~= nil then cs.Value = cs.Value + 1000 --Change to the amount you want this to add end end end end end return Enum.ProductPurchaseDecision.PurchaseGranted end

This works but when in do the 500 cash [First script the same] Starterpack


local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") CASHID = 22197521 -- Put the Developer Product ID here MarketplaceService.ProcessReceipt = function(receiptInfo) local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId local numberBought = ds:IncrementAsync(playerProductKey, 1) for i,v in pairs (game.Players:GetChildren()) do if v.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == CASHID then lds = v:FindFirstChild("leaderstats") if lds ~= nil then cs = lds:FindFirstChild("Cash") --Change to your leaderstat if cs ~= nil then cs.Value = cs.Value + 500 --Change to the amount you want this to add end end end end end return Enum.ProductPurchaseDecision.PurchaseGranted end

This does not work... And i already did change

local numberBought = ds:IncrementAsync(playerProductKey, 1) --To 11 or 14 (14 is number where product is)

I hope some one can help me Thanks you :)

0
Try just combining the two scripts into one, then putting the one script in the ServerScriptService. Tkdriverx 514 — 9y

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

To have multiple Developer products, you have to check the ProductId of the receiptInfo. And you'd have to have separate Developer Products.

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local thousandCash = 00000 --Put the ID for the thousand cash buy
local five_hundredCash = 000000 --ID for 500 cash buy

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
    local numberBought = ds:IncrementAsync(playerProductKey, 1)
    for i,v in pairs (game.Players:GetChildren()) do
        if v.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == five_hundredCash then
                local stat = v.leaderstats:FindFirstChild("Cash")
                if stat ~= nil then
                    stat.Value = stat.Value + 500
                end
            elseif receiptInfo.ProductId == thousandCash then
                local stat = v.leaderstats:FindFirstChild("Cash")
                if stat ~= nil then
                    stat.Value = stat.Value + 1000
                end
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end
0
and if i need more i can do this look down! ;p minetrackmania 186 — 9y
0
Do it need a local script? or just a script into starterpack minetrackmania 186 — 9y
1
Regular script in Workspace(: Goulstem 8144 — 9y
0
Okayy thanks it works :) I have now for 10 more ;) minetrackmania 186 — 9y
Ad

Answer this question