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.
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.
01 | local prodId = 1 |
02 | MarketplaceService.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 |
16 | end |
If I helped you up vote and accept my answer as the official answer.