Dev Product gifting system

How do I create a gifting system where users can gift dev products to their friends by entering their friends username. What events of Marketplaceservice must I use to achieve this system?

It seems that ProcessReceipt does not accept custom parameters, so I cannot send the user a player wants to gift to as a parameter, so how can I do this gifting system?

1 Like

you could have the “gifter” pay for the item after they select the person they’re gifting to.
press a gift button and choose/enter a player and prompt a purchase

Maybe have it as a separate devproduct.
Example:
+100 Coins - buying for yourself
Gift 100 Coins - buying for others

The reason ProcessReceipt does not accept custom parameters is so that you can’t force other players to spend robux on products. You can make it so that when the purchase goes through, it would take the userId of the player you wished to receive the currency and add the currency to that userId.

Example (I modified the code from Handling Purchases):

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local targetPlayerId = -- enter the friend's id here however you wish

local productFunctions = {}

productFunctions[123123] = function(receipt, player)
	if player then
	    -- Give the targetPlayerId the dev product however you wish here (example below)
			game.Players:GetPlayerByUserId(targetPlayerId).leaderstats.Currency += 100
		-- Indicate a successful purchase
		return true
	end
end

local function processReceipt(receiptInfo)
	local userId = receiptInfo.PlayerId
	local productId = receiptInfo.ProductId

	local player = Players:GetPlayerByUserId(userId)
	if player then
		local handler = productFunctions[productId]
		local success, result = pcall(handler, receiptInfo, player)
		if success then
			return Enum.ProductPurchaseDecision.PurchaseGranted
		else
			warn("Failed to process receipt:", receiptInfo, result)
		end
	end

	return Enum.ProductPurchaseDecision.NotProcessedYet
end

MarketplaceService.ProcessReceipt = processReceipt
1 Like

Thank you, but how would I let the server know who I am gifting to? I was thinking to fire a remote on a line above prompting the purchase that would send the text-box of the username that was input then server received that as an arg and stores it, but that seems like a hacky method, so i’m wondering how to inform the server i.e.

I want to give Player1234 500 currency from buying this dev product, but how to send Player1234, so that it gives Player1234 the 500 currency and not me that bought it

let me know what your answer is to the reply above ^ when your free please

My apologies for the late reply. I don’t think that your method of sending the text-box username from the client is hacky at all, I think that’s a reasonable method. I would absolutely make sure to implement sanity checks on the server, example: making sure that the spelling is correct before the first player buys the product for the friend. Just convert the username on the server to an UserId, and use the targetPlayerId of the player receiving the gift here:

1 Like

Alright thanks for reply. For example would this seem hacky


ServerEvent:FireServer(GiftUser.Text)
MarketPlace:PromptProductPurchase(Player, 12343242)

So basically what im doing is firing a event every time a player prompts to purchase a dev product, and that event will send as an argument the username they want to gift to

1 Like