@Dark
SubscriptionService is still on Beta, and it can have unknown bugs relating to Robux Purchases. Please consider using it for meanwhile developing. If any bug is found, we’ll update as fast as possible to fix it.
Total Bugs Fixed (relating to purchases) 2
You shall never REQUIRE SubscriptionService on the Client.
While you are welcome to modify and use this module as you see, I recommend using a require by ID ( local Subscriptions = require(12016079866)
) to ensure that you are always using the most up-to-date version with all bug fixes and updates applied. This will help ensure the smooth and reliable functioning of your subscriptions.
SubscriptionService is a roblox module for creating custom subscription plans for your game.
It’s easy-to-use and haves a lot of customizable options, with that, you can create a plan that fits your game and your players’ needs.
Well, it’s very easy.
- You
require
the module. - You create subscriptions, using
createSubscription(data)
- You
PromptRenewSubscription(info)
when the user joins. - Tada! You have subscriptions.
If you are still having trouble understanding the concept, the following code example may help.
Creating a subscription
It’s really easy to create a subscription. You call :createSubscription({})
with your subscription data and the subscription will create.
local Subscriptions = require(12016079866)
local isSubscriptionCreated = Subscriptions:createSubscription({
SubscriptionName = "PRO",
DeveloperProductId = 1351971825,
SubscriptionExpire = "1m",-- SUPPORTED => min (minute), d (day), w (week) m (month), y (year)
freeTrial = { -- TODO => FOR NEXT UPDATE
enabled = false,
trialExpire = "2d"
},
upgrades = { -- THIS WILL SHOW IN THE PURCHASE PROMPT ;;; JUST 3
[1] = "30% more money",
[2] = "20% boosted attack damage",
[3] = "{MORE}", -- will change to "and much more!"
}
})
All of the fields in the
createSubscription()
method are required in order to create a new subscription.
This code creates a new subscription for a Roblox game. The subscription is called “PRO” and has a developer product identifier of 1351971825
. The subscription will expire after a specified amount of time, which can be specified in units of minutes, days, weeks, months, or years (e.g. “1m” for one month).
The freeTrial
field is intended for a future update and is currently disabled.
The upgrades
field lists three potential upgrades that will be displayed in the purchase prompt for the subscription. These upgrades include “30% more money”, “20% boosted attack damage”, and “{MORE}”, which will be changed to “and much more!” in the final version.
Prompt the player to buy/renew subscription
Players.PlayerAdded:Connect(function(player)
Subscriptions:PromptRenewSubscription({
target = player,
showIfNotPurchased = true, -- false: show when sub ended | true: show if user does not have subscription
subscriptionName = "PRO",
}) -- if user already haves a subscription, it won't do nothing.
player.CharacterAdded:Connect(function()
checkSubscription(player)
end)
end)
Every time a new player joins the game, they will be prompted to purchase the “PRO” subscription.
If you don’t use the function and their subscription expired, they will automatically see the Renew Prompt.
If you want to use a GUI button to purchase the subscription, you should run the PromptRenewSubscription()
method with the showIfNotPurchased
argument set to true
. This will display the prompt to players who have not purchased the subscription yet.
SubscriptionChanged
Subscriptions.subscriptionChanged
is an event that is triggered on the module
object whenever a player’s subscription status changes.
The code sets up a connection to this event and specifies a function to be called when the event is triggered. The function takes two arguments: player
, which is the player whose subscription status has changed, and newSubscription
, which is a string representing the player’s new subscription status.
When the event is triggered, the function calls the checkSubscription()
function, passing in the player
argument as an input. This causes the checkSubscription()
function to be called and the player’s subscription status to be checked and updated accordingly.
Subscriptions.subscriptionChanged:Connect(function(player, newSubscription)
-- for example, check if the user haves subscription and add a nametag on their head
-- or remove the nametag if the user does not have a subscription
-- newSubscription format:
-- {subscription = "NONE", userHavesSubscription = false} // {subscription = "PRO", userHavesSubscription = true, expiry = 1704063570, userSubscriptionId = 1351971825}
end)
code descriptions by ChatGPT
Full Code Example
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Subscriptions = require(12016079866)
local isSubscriptionCreated = Subscriptions:createSubscription({
SubscriptionName = "PRO",
DeveloperProductId = 1351971825,
SubscriptionExpire = "1m", -- SUPPORTED => min (minute), d (day), w (week) m (month), y (year)
freeTrial = { -- TODO => FOR NEXT UPDATE
enabled = false,
trialExpire = "2d"
},
upgrades = { -- THIS WILL SHOW IN THE PURCHASE PROMPT ;;; JUST 3
[1] = "30% more money",
[2] = "20% boosted attack damage",
[3] = "{MORE}", -- will change to "and much more!"
}
})
local function checkSubscription(player, sub)
local success, error = pcall(function()
local userSubscription = sub ~= nil and sub or Subscriptions:getSubscriptionForUserIdAsync(player.UserId)
-- {subscription = "NONE", userHavesSubscription = false} // {subscription = "PRO", userHavesSubscription = true, expiry = 1704063570}
if (userSubscription.userHavesSubscription) then
local head = script.BillboardGui:Clone()
head.TextLabel.Text = userSubscription.subscription
head.Parent = player.Character.Head
head.Adornee = player.Character.Head
else
if (player.Character.Head:FindFirstChild("BillboardGui")) then
player.Character.Head:FindFirstChild("BillboardGui"):Destroy()
end
end
end)
if not success then
warn("Something happened while checking user's subscription: " .. error)
end
end
Players.PlayerAdded:Connect(function(player)
Subscriptions:PromptRenewSubscription({
target = player,
showIfNotPurchased = true, -- false: show when sub ended
subscriptionName = "PRO",
}) -- if user already haves a subscription, it won't do nothing.
player.CharacterAdded:Connect(function()
checkSubscription(player)
end)
end)
Subscriptions.subscriptionChanged:Connect(function(player, currentSubscription)
checkSubscription(player)
end)
This code shows the user every time that joins a subscription prompt to purchase PRO
(it will just show to people that don’t have any subscription). If the user haves a subscription it will add a text in their head with their subscription name. If the subscription expired meanwhile in-game, the text will remove. And if the user joins, and do not have a subscription, nothing will happen.
(i made this description yay )
Tips
Here are a few tips to consider when trying to get players to buy your in-game subscription:
from ChatGPT
- Offer exclusive content or perks: Players are more likely to buy a subscription if they feel they are getting something special in return. Consider offering exclusive in-game items, special discounts, or early access to new content as part of the subscription package.
- Communicate the value: Make sure players understand what they are getting for their money. Clearly communicate the benefits of the subscription and how it will enhance their gameplay experience. added by me: make it easy to understand
- SOON ON SUBSCRIPTIONSERVICE Offer a free trial: Consider offering a free trial period to give players a chance to try out the subscription before committing to a purchase. This can help build trust and show players the value of the subscription.
- Make it easy to purchase: Make sure the subscription is easy to find and purchase within the game. If it’s difficult for players to find or purchase the subscription, they may be less likely to do so.
- Consider offering multiple subscription options: Some players may be willing to pay more for additional perks or content, so consider offering multiple subscription tiers to cater to a range of budgets.
You can also use Rich Text in the upgrades. For example, “30% more money”. Put “more money” on bold or bigger. (SubscriptionService will automatically put it on bold.), but you can customize like you want.
It’s based off the Roblox Premium Purchase Prompt (super similar). To purchase a subscription, users can follow the prompts within the Roblox platform to purchase with Robux. The subscription will then be activated and the user will have access to the subscription in your game.
You are responsible for creating GUI buttons or workspace parts with onTouched
scripts that allow the user to select a subscription.
Images
Example with PRO
subscription:
ignore 20 per minute, it’s for testing purposes
I used some Roblox Images, (like the close button) and Color-Picked Roblox Dark.
The Roblox-verified icon is a Replacement Character used by Roblox
Did you know…?
Roblox haves 3 Replacement Characters:
Verified Mark () | Premium Icon () | Robux Icon ()
You can use it in your games!
If a player haves a subscription, it will add an attribute to Player with the Timestamp (when the subscription expires). game:GetService("Players").LocalPlayer:GetAttribute("SubscriptionExpire") --> example: 1672826270
Coming soon new updates on the DevForum Post
See you!
Test Game
You don’t actually have to purchase. You can just play with it there.
- 5
- 4
- 3
- 2
- 1
0 voters