Hey Devs! Today I will be showing you a premium purchase prompt that will allow players to purchase Premium membership through your game. We will also make a frame that will show the perks that the player will be given by being a Premium user. Unfortunately, you get nothing when someone buys Premium through your game, but there’s more chance that you will have more Premium players (More premium players, more money through Premium Payouts). It is not very unique, but there’s no reason to not adding this feature to your game!
What is the Premium Purchase Prompt?
Premium Purchase Prompt is a premium purchase prompt. After you do your action, a prompt appears with the option to buy a Premium membership.
The prompt is not customizable.
How to add it?
You can enable it by making a script. For this example, a prompt will appear when a player touches a part.
Make a script in your part.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gui = script.Parent
local showPrompt = true
local function PerksGui(other)
local player = Players:GetPlayerFromCharacter(other.Parent)
if not player then return end
if player.MembershipType ~= Enum.MembershipType.Premium then
if showPrompt == false then return end
showPrompt = false
delay(5, function()
showPrompt = true
end)
MarketplaceService:PromptPremiumPurchase(player)
warn("Prompted Premium purchase!")
print("Part touched!")
end
end
gui.Touched:Connect(PerksGui)
MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player)
end)
There are probably more different easier ways to do this, but I made it with instructions on the DevHub.
Now, when we touch our part a prompt appears. Everything is done in MarketplaceService
so we need to check if the purchase was successful.
Purchase Premium Buttons
I made a simple button and a frame with all perks for premium members. When I click the “Premium” button a frame with perks appears. I added an invisible textbutton on the whole PremiumButton so we don’t need to copy the scripts.
Now it’s time for some scripting. Let’s start with the buttons.
I add a localscript into the invisible textbutton:
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.Premium.Visible = true
print("A player has opened the premium perks frame!")
end)
and for the exit button in our “Premium” frame.
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.PremiumButton.Visible = true
print("A player has closed the premium perks frame!")
end)
Of course, you need to reference everything differently in your game. This is a tutorial.
And we got it!
Our last part is to make the “Buy Now” button work.
We add a localscript to our buy now button.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local gui = script.Parent
gui.MouseButton1Down:Connect(function()
if player.MembershipType == Enum.MembershipType.Premium then
return
end
MarketplaceService:PromptPremiumPurchase(player)
end)
And we get this prompt after we click the buy now button!
Thanks!
Thanks for reading my tutorial and hopefully I showed you something that could make your next game better. Don’t expect master class scripting here, I’m learning too. My only goal in these tutorials is to show everyone easy and unique features that you could add to your game.
Check out my last tutorial! Avatar Context Menu
DevHub Link: PromptPremiumPurchase
In the end, I want to say thank you to @ for helping me with the Buy Now button script!