MarketplaceService Module [Easily set up developer products & gamepasses] [Open Sourced]

Intro:
Hey all! It’s been a while since I’ve posted a resource to the public. This module is pretty simple currently but can help new developers getting started with monetizing their games. This module uses an auto-updater in the event of bugs but you can fork this if you’re concerned about game security. I made this in about two hours because I need it for new games in the future but I decided to release it because I have literally nothing to lose.

This module allows you to add functions to gamepasses & developer products much more quickly if you didn’t already have a system built for your game by connecting them to events. You can even add it using a single line of code!

Events:

  • premiumPlayerJoined
  • onDeveloperProductPurchase
  • gamepassPurchased
  • gamepassOwned

Documentation:

  • premiumPlayerJoined

This event will be called whenever a premium player is found in the game. This does not need to be added when the game starts as it’ll go through all of the existing players when you first link it. It’ll also fire when a user buys premium ingame or online. This function will always be called with a player linked to it.

local marketplace = require(7268166176)

marketplace.premiumPlayerJoined:Connect(function(player)
    print(player,"has premium!")
end)
  • onDeveloperProductPurchase

This event will fire with the player and the “receipt” whenever someone in your game buys the specified developer product.

A receipt is structured like this (as an example)

{
   currencyType = "Robux", --> This value *probably* won't change.
   placeIdWherePurchased = 1234567890,
   playerId = 1,
   productId = 123456,
   purchaseId = "4266bf8d3dc65bc84fd3badf2edfdbe7"
}
  • developerProductId <int>
local marketplace = require(7268166176)

marketplace.onDeveloperProductPurchase(123456):Connect(function(player,receipt)
     print(player,"bought an epic gamer product!")
end)
  • gamepassPurchased

This event is fired whenever someone buys the specified gamepass ingame and does not check if they own it when they join the game (the next event does this).

  • gamepassId <int>
local marketplace = require(7268166176)

marketplace.gamepassPurchased(12345678):Connect(function(player)
    print(player,"bought the VIP gamepass!!!! :ooo")
end)
  • gamepassOwned

This event is similar to the premium one. It will automatically fire whenever someone in the game already owns the specified gamepass. It will also fire when they purchase it ingame. Each time it is connected, it’ll check all the players.

  • gamepassId <int>
local marketplace = require(7268166176)

marketplace.gamepassOwned(123456):Connect(function(player)
    print(player,"now owns vip")
end)

More information:

  • The module’s source code can be found here.
  • I’d recommend using the require function in the event there are bugs, but if you’re worried about security issues feel free to fork it!

If you have any issues with this module, report it to me & happy developing!

Would you use this module in your game?
  • Yes
  • No

0 voters

On a scale of 1-10 how helpful do you think this module would be to you?
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

0 voters

My other public resources:

20 Likes

Does it fire every frame? Every second? Because if a player owns a gamepass. They own it forever.

Instead, I think you should simply make a function, .ownsGamepass(id) which returns a boolean

1 Like

Sorry, bad wording on my behalf. It loops through all the players when you connect it and then links it to PlayerAdded if that makes any sense.

2 Likes

Why should I use this over the main Roblox marketplace service? It pretty much looks like the same thing, but with a premiumPlayerJoined function(which isn’t hard to make).

I would be grateful if you could give me a comparison of your system, against Roblox’s system.

It is the same thing technically, but it’s all down to preference. I made this so I could have a faster way of setting up developer products & gamepasses for new games I’m making. It could be helpful to you because it handles everything for you in one line of code instead of you having to set up the MarketplaceService events yourself.

Another reason is for new scripters, Roblox can be very intimidating and this makes setting up MarketplaceService super simple while they can even learn from the source code.

2 Likes

Not really, what makes you say that? If you’re saying it because of the code, that’s my documentation not a tutorial. Also why’d you necropost it?

1 Like

Hey Jumpathy, I don’t think enough people give other developers the credit they deserve.

My shop processing started to get very messy and things started breaking, this helped me clean up my code and it works flawlessly. Thank you for putting this out there! Sorry for another necro.

1 Like

Not to be nit-picky, but this doesn’t follow the Lua naming convention. Functions should use the Sentance case.
premiumPlayerJoined → PremiumPlayerJoined

PS: Looks cool!

I mean, the biggest deal here is easy developer product handling