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

How do you give a player who buys a developer product an item?

Asked by 10 years ago

I have a GUI that is attached to a Developer product, which costs 5 R$. I am having troubles, however, giving the player who buys it a item (Gun, sword, or any anything else). I have tried to script it, and even tried FM's. Is there a specific code that does this? If so, what is it?

To this hour, I have spent two days looking for it and I am frustrated.

0
I already looked there but thanks for the comment. adspace44 20 — 10y

1 answer

Log in to vote
2
Answered by
Gamenew09 180
10 years ago

I've went through the same pain you did. Basically you look for the player then check what product the player bought then add the item. What I do for PvP Battle. All you have to do is change what is in the if statement for the product id checker.

local prodId = 1
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(tonumber(receiptInfo.ProductId) == prodId)then
                --TODO: Buy the Ocherous Katana of the Setting Sun
                game.InsertService:LoadAsset(25545089).OrangeKatana.Parent = player.Backpack
                game.InsertService:LoadAsset(25545089).OrangeKatana.Parent = player.StarterGear
            end
        end 
    end
    -- tell ROBLOX that we have successfully handled the transaction (required)
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

If I helped you up vote and accept my answer as the official answer.

0
does this go in local or server script and placed where?4 NinjoOnline 1146 — 10y
0
Server Script, ServerScriptStorage Gamenew09 180 — 10y
Ad

Answer this question