Tutorial for making a premium marketplace system

Hi everybody! Welcome back to my tutorial on making a marketplace system.

Most games have special offers for when you get premium.
RobloxScreenShot20220516_085940886

For this tutorial, I will be showing you how to make premium benefits for games.

STEP 1: What benefits will you make?

You can think of any premium benefit. It can be a tool, access to a certain area, extra coins, etc. But let’s just stick with coins for now.

Now think about how many coins you want to give the player:

  • 10 Coins
  • 25 Coins
  • 50 Coins
  • 75 Coins
  • 100 Coins

And think about the time between the player will receive the coins:

  • 1 Minute
  • 2 Minutes
  • 5 Minutes

Usually, I would do 50 coins every 2 minutes of play but you can pick any of the above :smiley: !

STEP 2: Making the premium GUI

Now we’re gonna move on to the GUIs. Here’s how we’re gonna do it:

  1. Create a new screen gui in starter gui.

  2. Add a new frame in the screen gui and name it, “Open”. Set the anchor point as 0.5, 0, 0.5, 0. Position it to the bottom right of your screen.

  3. Add a new image button and place it in your frame. Set the anchor point as 0.5, 0, 0.5, 0 and position it inside the frame.

  4. Find a premium membership label for your image button. Make sure that it’s a PNG image.

So at the end, your button should look like this:

For our other gui, which is going to have the premium benefits we’re gonna:

  1. Add another frame inside the same gui and name it, “Premium Benefits”.
  2. Set the same anchor point from earlier and this time, position the frame in the middle of the screen.
  3. Resize the frame to fit your list of premium benefits.
  4. Add text labels for your benefits and a title saying. “Premium Benefits”. Don’t forget to resize the text to make it visible to players.
  5. Add your button at the bottom of the frame and another one for when you close the frame.

So in the end, the frame should look like this:
RobloxScreenShot20220516_085940886

STEP 3: The coding!

Finally, you have reach the coding step! Now to start off, make sure API, third party sales and HTTP are enabled (Game Settings > Security).


(I forgot to enable HTTP in this screenshot. Sorry about that.)

The server script

Add a regular script inside ServerScriptService. If you have more than one script inside there, I highly recommend naming them to avoid confusion. Now follow what I do:

Create a function for when a player joins the game. Name the parameter, “player”.

game.Players.PlayerAdded:Connect(function(player)
     -- Do stuff
end)

Next, we’re gonna check if the player joined with premium or not. So add a conditional statement inside the function:

if player.MembershipType == Enum.MembershipType.Premium then
     -- Do stuff
end

So earlier in the tutorial, we set up our premium benefit. Again, let’s say the player will get 50 coins every 2 minutes of play. Therefore we add a loop and set it up like this:

if player.MembershipType == Enum.MembershipType.Premium then
     while wait(120) do -- 120 seconds for two minutes
          player.leaderstats.Coins.Value += 50
     end
end

Make sure you have your leaderstats script, otherwise, you’ll get an error.

So, Volià! Your server script should look like this:

game.Players.PlayerAdded:Connect(function(player)
     
     if player.MembershipType == Enum.MembershipType.Premium then
          while wait(120) do -- 120 seconds for two minutes
               player.leaderstats.Coins.Value += 50
          end
     end
     
end)

The button script

Now let’s move on to the gui script. Add a local script in the premium benefit frame that will look like this:

local Frame = script.Parent
local Premium = Enum.MembershipType.Premium
local premiumButton = Frame.Premium -- The get-premium button
local openPremiumButton = Frame.Parent.Open.OpenPremium -- The open-gui button in the other frame
local closePremiumButton = Frame.CloseShop -- The button to close the gui

local mps = game:GetService("MarketplaceService") -- Your marketplace service

local players = game.Players

Frame.Visible = false
closePremiumButton.Visible = false
openPremiumButton.Visible = true


openPremiumButton.MouseButton1Click:Connect(function()
	Frame.Visible = true
	closePremiumButton.Visible = true
end)
	
premiumButton.MouseButton1Click:Connect(function()
	local player = players.LocalPlayer -- That's you!
	if player.MembershipType == Premium then
		return print("You already have Premium!") or mps:PromptPremiumPurchase(player)
	else
		mps:PromptPremiumPurchase(player)
	end
end)

closePremiumButton.MouseButton1Click:Connect(function()
	Frame.Visible = false
	closePremiumButton.Visible = false
end)

Thanks for reading

If I miss anything in this topic, you can feel free to remind me and I’ll be happy to edit. Again, thank you for reading! :grin: Also, if you want to work with gamepasses, here’s the link to the tutorial: (UPDATED) Tutorial for making a Marketplace System. Good luck! :+1:t5:

Was this helpful?

  • Yes it was! Thank you.
  • Nah. I already knew that :wink:

0 voters

By the way, if you have any problems, please feel free to reply to this topic or send me a message.

8 Likes

Good tutorial, but I would not recommend using so bright colors for UI like dark blue. Mostly only use black or white. (35, 35, 35) or (250, 250, 250)

2 Likes

Great Tutorial i do not recommend using wait instead task.Wait()

1 Like

Ok then. Thanks for the suggestion. :grin:

task.wait() is only for huge performance. like perfect frames. Wait will work just fine.

1 Like

wait() is alright for testing, but should not be used in production code for various reasons. Do your research.

3 Likes

Thanks! This really helped me in my game!

1 Like

I’m glad it did. Just in case, here’s the link to the original tutorial:
(UPDATED) Tutorial for making a Marketplace System

Alright Thanks, nice work by the way

1 Like

Tip for this tutorial: You can also use premium to double up values. For example, if someone touches an object and receives money, they can get double if they own premium.

script.Parent.Touched:Connect(function(Hit)
     local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
     
     if player then
          player.leaderstats.Coins.Value += 10
          if player.MembershipType == Enum.MembershipType.Premium then
               player.leaderstats.Coins.Value += 10*2
          end
          print("Player has successfully received money.")
     end

end)

Again, if I miss anything, please reply to this topic. Also, the object has to be a part.

1 Like