Best way to do gifting system

I’m wanting to add a gifting system where a player can buy a dev product and it’d give a player (work both online and offline) an item. This needs to work with dev products and not player items, like how Pls Donate works. However I’m unsure best way to get what player you’re gifting to the server. At the moment, you input a player name into a textbox and click buy, dev product prompts, but when purchase is complete, there’s no ideal way of knowing who you gifted to on the server. My only thought is sending the player name to the server too, but unsure if there could ways of either manipulating or it breaking, meaning nobody gets the gift but you’ve spent robux

Example of what I’m doing

GiftFrame.ClipContainer.Buy.Button.Activated:Connect(function()
	if not self.GiftingUserId then
		NoticeController:Prompt("You haven't put a valid username in the gift box above", "Alert")

		return
	end

	if self.GiftingUserId == Player.UserId then
		NoticeController:Prompt("Sorry, you can't send yourself gifts", "Alert")

		return
	end

	if SendingGift then
		return -- Debounce buffer
	end

	SendingGift = true

	PurchaseController:Open()

	local Success, Message = StoreService:GiftingUserId(self.GiftingUserId)
	if Success then
		MarketplaceService:PromptProductPurchase(Player, giftData.Id)
	else
		NoticeController:Prompt(Message, "Alert")
	end

	SendingGift = false
end)

And the server will basically do server side checks (no invalid ids/sending to self) and if clears, server will store in a table your player and the userid you want to send to, and then client will allow you to purchase product.

Once product purchsaed, server will check and if it finds your player attached to a userid, itll send that userid a gift. if no userid, then :man_shrugging: too bad so sad I guess??

and when player leaves, it’ll remove any trace from the server store to prevent tables being massive.

The biggest issue however is I am using ProfileService, and thus, if a player has never played the game before, they won’t get the gift :grimacing:

3 Likes

Never made such a system, but the way I would probably do it is by making it so on client when you type the name of the player you want to gift to and press buy, server would get their userid, check if that player exists, if its not you, if they have ever played the game and if they own the item you are gifting (if its a one time purchase). If all those checks pass you can then prompt the player to buy the product, if not then just throw an error. Id probably also add gifts into the datastore so you can show the player who has been gifted that someone has gifted them an item. Also maybe use MessagingService to instantly show the player they have been gifted if they are currently ingame.
With gifts in the datastore you could also make it so they dont instantly get the item but instead they can claim it when they join the game next.

1 Like

I think that among all the ideas you’ve already had, you’re covering most of the aspects. One initial thought that comes to my mind is, if you’re capable of creating a system like this, why continue using the ProfileService? Clearly, you could design your own custom saving system. Especially if that module could create obstacles for the implementation of your new features…

When you mention that the “gift” could be given to a player “within the server”, and you also mention that it should “work online/offline”, and since you mention problems in verifying that the user doesn’t spend their Robux unnecessarily, I don’t understand why you couldn’t simply validate that the “receiver” 100% exists and store it in DataStoreService (DSS) until they log in (even if it’s their first time) and regardless if player is in server or another one (across servers) or none.

I don’t think validating the “receiver” should be a major concern since you could provide very thorough checks to the “sender” before the sender accepts to pay the Robux, including checking that the name can be found on Roblox as a valid account, ID, and even displaying their thumbnail with their name and ID to the sender, and clearly storing it when the purchase is done.

Here, @NinjoOnline, try this!
How to make a GAMEPASS GIFTING SYSTEM | ROBLOX STUDIO - YouTube
Hope this helps!