Way to detect when a player buys a dev product

I am currently using this event to detect whenever a dev product has been purchased, is this bad to use, if so why? I am using it to allow players to gift gems and coins to their friends

MarketPlaceService.PromptProductPurchaseFinished:Connect(function(userId, productId, isPurchased)

end)

Server-side Module script:

promptPurchaseEvent.OnServerEvent:Connect(function(player, id, giftToPlayer)
	prodModule.buyProducts(player, id, giftToPlayer)
end)


function module.buyProducts(Player, ProductId, PlayerToGift)
	if not ProductPurchasedCD[Player] then
		ProductPurchasedCD[Player] = true
		MarketPlaceService:PromptProductPurchase(Player, ProductId)
		giftTable[Player.UserId] = Player
		if PlayerToGift and game.Players:FindFirstChild(PlayerToGift) then giftTable[Player.UserId] = PlayerToGift end
		if PlayerToGift and game.Players:FindFirstChild(PlayerToGift) then
			game.ReplicatedStorage.Events.SuccessEvent:FireClient(Player, "Notify", {Color = Color3.fromRGB(255,255,255), Text = "Gifted To: ", NewItem = false, MultiColor = false, Coloured = true, StartColoured = '<font color= "rgb(48, 255, 132)">', End = "</font>", ColouredText = tostring(game.Players:FindFirstChild(PlayerToGift)), CustomSound = 2650044156})
		end
		task.wait(1)
		ProductPurchasedCD[Player] = false
	end
end

MarketPlaceService.PromptProductPurchaseFinished:Connect(function(userId, productId, isPurchased)
	print("purchased")
	if isPurchased and giftTable[userId] then
		module.GiveProducts(giftTable[userId], productId)
		if giftTable[userId] and game.Players:GetPlayerByUserId(userId) ~= giftTable[userId] then
			game.ReplicatedStorage.Events.SuccessEvent:FireClient(giftTable[userId], "Notify", {Color = Color3.fromRGB(255,255,255), Text = "You've been gifted by ", NewItem = false, MultiColor = false, Coloured = true, StartColoured = '<font color= "rgb(48, 255, 132)">', End = "</font>", ColouredText = tostring(game.Players:GetPlayerByUserId(userId)), CustomSound = 2650044156})
		end
		if giftTable[userId] and game.Players:GetPlayerByUserId(userId) == giftTable[userId] then
			game.ReplicatedStorage.Events.SuccessEvent:FireClient(giftTable[userId], "Notify", {Color = Color3.fromRGB(255,255,255), Text = "Successful Purchase", NewItem = false, MultiColor = false, Coloured = false, StartColoured = '<font color= "rgb(48, 255, 132)">', End = "</font>", ColouredText = nil, CustomSound = 2650044156})
		end
	end
end)

Use this event of MarketplaceSerivce: PromptProductPurchaseFinished.

You can use the devproduct receipt to achieve what you’re looking for.

But product receipt does not accept custom parameters, so how will I be able to make a gifting system for players to gift products to other users?

I meant for it to be a detector about who bought it (e.g. the player’s id) which you could then turn into a string value then use the player id they input and make that a stringval and it would give them the item/cash/etc. If you’re custom parameters regard some other factor that is not shown on the receipt then sadly I can’t help you there. Good Luck! :+1: