Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

2 comments

0

I already looked there but thanks for the comment.

1 answer

✓ Accepted answer

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.

2 comments

0

does this go in local or server script and placed where?4

0

Server Script, ServerScriptStorage

This discussion is preserved as it was. New answers, comments, and votes are closed.