A way to award players items

As a Roblox developer, giving players free items (gamepasses, developer products) to friends/via codes/etc. is currently impossible. Currently to do so, you would need to implement an unofficial system that handles things.

While you could say I could just go into my Data Store and edit the user’s stats, in the case of a gamepass, a player could end up wasting their money on a gamepass that they may already ‘own’ from other means.
This could also be utilised in the future whenever UGC comes out and developers could award wearable items to their players.
Finally it would lower the workload a small bit for developers.

Suggestion

I think a little server-only API like MarketplaceService:AwardAssetToUser(id UserId, id AssetId) would be quite useful.

This could also treat the awarding like a purchase so that ProcessReceipt and other relevant events are called/fired.

27 Likes

Actually, those “free items” gifted to players are called badges.

Yeah but for things like gamepasses that you can also buy. Or developer products, which can be bought many times as opposed to a single badge.

You would also need to setup a system for processing the free items, whereas with gamepasses/developer products you already have things setup to process them.

1 Like

You can have a badge, and a developer product that awards that badge.

I’m not looking to give people badges, I’m looking to give people gamepasses/developer products.

Badges can only be taken once (so developer product functionality is lost) and cannot be bought (so gamepass functionality is lost).

However I guess a badge could be used in a passe’s situation - but it’s not what badges are for, and is just a weird way to get around the actual problem. It also still leaves the issue with gamepasses where you could still buy something you already own through other means.

1 Like

Do you really need a (edit: developer product) to give someone an award multiple times? If you want to award a player 1000 coins, just… award them 1000 coins. That doesn’t stop you from having a 1000 coin developer product.

He’s saying it’s hard to create a system to give out codes for 1000 coins that he can hand out to fans or on twitter or in a giveaway etc

How would giving the developer the ability to award developer products achieve that goal? You can already achieve that goal now by just awarding them 1000 coins in-game by punching in a code.

1 Like

I think he just means he wants an easy system to create unique 1 use codes for these things

1 Like

That’s OP’s usecase, but OP’s suggestion of adding a MarketplaceService:AwardAssetToUser(id UserId, id AssetId) API makes me think that they want a way of awarding assets to players. I don’t see how giving the ability to award assets to players helps advance the usecase.

1 Like

It’s not primarily developer products - it’s gamepasses.

The problem is that you can’t ‘set’ a gamepass as bought for a specific player. If they somehow earn the contents of the gamepass (e.g. twitter code), they are still be able to buy the gamepass - when they already have what it gives anyway.

2 Likes

Then the player can just not buy it? Use a developer product instead?

Yeah…I think I get what your trying to say.
I think the best route here is to make your own custom system to have this doen. I mean, its not that hard. You could even make it some daily crate or something, or a special occasions thing. I think that at this point it’s too custom to make this a solid feature. Lots of people use these types of systems. You could ask in development discussion how you would go about to do this in the most simplistic way. This feature would be too specific to actually exist though.

1 Like

You guys are totally missing the point… I support this.

10 Likes

I don’t see how the use case described by OP can’t be accomplished right now. Why do you even need to invoke ProcessReceipt (by giving an asset to the player) when you can just apply the developer product’s effect directly to the player once s/he enters the code?

As for gamepasses, why not use developer products instead and make a check to make sure that the player can’t purchase the developer product if a) they have already purchased it or b) they’ve already redeemed its effect via code?

For both of these cases, the implementation shouldn’t be too complicated. For the first one, you should properly organize your code such that the function that awards the player the bonus is separated from your ProcessReceipt callback.:

-- In a server-side module.
-- Function that gives the player 1K points
function AwardPoints(player)
    -- This is a stub.
    -- Awarding function goes here.
end

-- In a server-side script.
-- Receipt-processing code
function MarketplaceService.ProcessReceipt(receiptInfo) 
    local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
    if receiptInfo.ProductId == 1234 then
        AwardPoints(player)
    end
end

-- In a localscript in the player's gui.
-- This is the text box for the code form.
TextBox.FocusLost:Connect(function()
    -- Fire a remote event that will send the input of this field to the server.
    -- The server will validate it on their side.
    CodeRemote:FireServer(TextBox.Text)
end)

-- In a server script.
-- This is the code for the server script that will listen to the remote event.
CodeRemote.OnServerEvent:Connect(function(player, code)
    if code == "YourCodeHere" then
        AwardPoints(player)
    end
end)

If MarketplaceService:AwardAssetToUser(id UserId, id AssetId) were to be implemented, we would replace the code of the remote event listener to:

CodeRemote.OnServerEvent:Connect(function(player, code)
    if code == "YourCodeHere" then
        MarketplaceService:AwardAssetToUser(player, 1234)
    end
end)

Which actually ends up making the code longer.

As for the second one (using a developer product to simulate game pass behavior) you could implement it the following way:

function PlayerHasBeenAwarded(player)
    -- This is a stub.
    -- Retrieves a boolean in the player's datastore which indicates whether or not the
    -- pseudo-game pass has been awarded.
end

function AwardPlayer(player)
    -- This is a stub.
    -- Awards the player 1K points.
    -- In addition, the bool that indicates that the award has been given is set in the datastore.
end

-- Tries to award the player.
-- Will do nothing if the award has already been awarded in the past.
function TryToAwardPlayer(player)
    if not PlayerHasBeenAwarded(player) then
        AwardPlayer(player)
        return true
    end
    return false
end

-- For ProcessReceipt, the previous code is fine.
-- Ditto for the code entry, but instead of AwardPlayer, do TryToAwardPlayer instead.
-- Maybe even present a message to the player if the code has already been redeemed?

-- Code for the in-game buy button.
-- Assume that the appropriate remotes are in place.
BuyButton.Mouse1Click:Connect(function()
    -- If the player has already obtained this award, whether via code
    -- or via dev product, then do not let them purchase this.
    -- Optimally, if the player already received the award, they wouldn't even see this button.
    if PlayerHasBeenAwarded(localplayer) then
        print("You already have this!")
    else
    -- Otherwise, go ahead and allow them to buy it.
        PromptPurchase(localplayer, 1234)
    end
end
3 Likes

Gamepasses are the main problem here if you award a gamepass ingame they have it. The problem is when the player can still purchase it from the site, you can’t do a receipt process at all and block the purchase.

(EDIT: Just noticed you mentioned replacing gamepasses with dev products, now I do see that being an option. Although, the primary problem is users will be confused where to go, as usual, the games they play have gamepasses in the shop tab. Which in this case would be way out of place, with the added possibility that there might be loss in sales)

EDIT 2: AND THANK YOU COLDSMOKE FOR CONFIRMING MY SECOND POINT IN THE FIRST EDIT,

3 Likes

Ooh hey I can give input again here

I actually made my own system for gamepasses in HomeBuilder2 using devproducts, I did this so that people could “gift” gamepasses to other players

It works pretty alright, but “gamepass” sales are EXTREMELY low compared to my last game. This could be for a number of reasons but I think them not being available on the game page is one big reason. I also have this anxiety that somehow the datastores are going to mess up cause me to have to give out a refund, although I’m alleviating this issue right now by using badges as “receipts” so if Saving/Loading fails the game has an alternative way to check if you own a pass

overall, wouldn’t recommend it.

4 Likes

See:

@XAXA That’s ok I guess, but it requires really good execution. What Spooks said pretty much says why.

I’d appreciate this feature very much, support. My friend has access to various VIPs in my game, and in the past people would say he’s hacking because on the website he doesn’t own the gamepasses for those VIPs. Creates a bad situation. So now, when a gamepass is made that I want to give him, we have to wait until the dead of the night, I change the gamepass to 1 R$, and let him buy it real quick. Kind of annoying to do.

1 Like

Support, it wouldn’t make sense for developer products, but makes perfect sense when it comes to game passes.

1 Like