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 11 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 — 11y

1 answer

Log in to vote
2
Answered by
Gamenew09 180
11 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.

01local prodId = 1
02MarketplaceService.ProcessReceipt = function(receiptInfo)
03    -- find the player based on the PlayerId in receiptInfo
04    for i, player in ipairs(game.Players:GetChildren()) do
05        if player.userId == receiptInfo.PlayerId then
06            -- check which product was purchased (required, otherwise you'll award the wrong items if you're using more than one developer product)
07            if(tonumber(receiptInfo.ProductId) == prodId)then
08                --TODO: Buy the Ocherous Katana of the Setting Sun
09                game.InsertService:LoadAsset(25545089).OrangeKatana.Parent = player.Backpack
10                game.InsertService:LoadAsset(25545089).OrangeKatana.Parent = player.StarterGear
11            end
12        end
13    end
14    -- tell ROBLOX that we have successfully handled the transaction (required)
15    return Enum.ProductPurchaseDecision.PurchaseGranted    
16end

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