Hi everybody! Welcome back to my tutorial on making a marketplace system.
Most games have special offers for when you get premium.
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 !
STEP 2: Making the premium GUI
Now we’re gonna move on to the GUIs. Here’s how we’re gonna do it:
-
Create a new screen gui in starter gui.
-
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.
-
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.
-
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:
- Add another frame inside the same gui and name it, “Premium Benefits”.
- Set the same anchor point from earlier and this time, position the frame in the middle of the screen.
- Resize the frame to fit your list of premium benefits.
- 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.
- 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:
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! Also, if you want to work with gamepasses, here’s the link to the tutorial: (UPDATED) Tutorial for making a Marketplace System. Good luck!
Was this helpful?
- Yes it was! Thank you.
- Nah. I already knew that
0 voters
By the way, if you have any problems, please feel free to reply to this topic or send me a message.