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

How to get Receipt info from LocalScript to ServerScriptStorage?

Asked by 10 years ago

Inside ServerScriptStorage (Sword1)

local MarketplaceService = game:GetService("MarketplaceService")
local sword1 = 20859896
MarketplaceService.ProcessReceipt = function(receiptInfo) 
    local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == sword1 then
                local Item1 = game.ReplicatedStorage.Swords.KnightsSword
                Item1:Clone().Parent = player.Backpack
                Item1:Clone().Parent = player.StarterGear
            end
        end
    end 
end

Inside ServerScriptStorage (Sword2)

local MarketplaceService = game:GetService("MarketplaceService")
local sword2 = 20859887
MarketplaceService.ProcessReceipt = function(receiptInfo) 
    local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == sword2 then
                local Item2 = game.ReplicatedStorage.Swords.Katana
                Item2:Clone().Parent = player.Backpack
                Item2:Clone().Parent = player.StarterGear
            end
        end
    end 
end

Inside LocalScript inside TextButton (Sword 1)

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

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

Inside LocalScript inside TextButton (Sword 2)

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

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

How come when the player clicks on button one to buy the sword they get the KnightsSword, but when they click the sword2 button they get the KnightsSword instead of Katana? I have it so when you buy it checks to see which one you brought to give the sword but it isnt working. Please help

0
Not sure, but i believe you should NOT, in fact, use "MarketplaceService.ProcessReceipt" twice. iaz3 190 — 10y
0
so how could I fix the problem? Make like a variable but change the variable name each time ?? NinjoOnline 1146 — 10y

Answer this question