SubscriptionService

image @Dark

:robux_light: SubscriptionService

BETA
easily create your own subscriptions!

roblox modulegithub


:warning: 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.

:1234: Total Bugs Fixed (relating to purchases) 2


:warning: 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.


How does it work?

Well, it’s very easy.

  1. You require the module.
  2. You create subscriptions, using createSubscription(data)
  3. You PromptRenewSubscription(info) when the user joins.
  4. 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 :slight_smile:)

Tips

Here are a few tips to consider when trying to get players to buy your in-game subscription:

from ChatGPT

  1. 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.
  2. 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
  3. 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.
  4. 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.
  5. 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.

How does it look? How people purchase the subscription?

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 :robux_light: per minute, it’s for testing purposes :man_shrugging:

image

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

:question: 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


:warning:Coming soon new updates on the DevForum Post

:wave: See you!


Test Game
You don’t actually have to purchase. You can just play with it there.

How would you rate this system? Keep in mind this is still on Beta, and future updates are in mind. Thanks!
  • 5
  • 4
  • 3
  • 2
  • 1

0 voters

52 Likes

Can I remake this? I like the idea of it and I feel like your approach wasn’t the best it could be. Anyways, great idea! I really think this could be useful, as i always wanted to create a subscription system like bloxburgs.

5 Likes

If you can give me any suggestion to improve this I’ll add it / improve it / change it.

But the way, if you feel like you want to remake it, you can. :slight_smile:

Happy developing!

1 Like

Oh thanks! I just want to clean up the code a bit and make the UI a bit better. I’ll be sure to share my contribution here.

2 Likes

I know it’s a bit messy, and if it’s the code maybe I’ll recomend you to wait for a full release.
And about the UI, you can do whatever. Maybe if it’s better than mine I’ll ask you if I can add it (and credit you).

2 Likes

Hey there! I improved your UI using the default premium prompt:

20 Likes

Hi again! I do like it (it’s almost the same) but here are some things I would change (in my opinion)

  • “For Subscription Only” :arrow_right: “Purchase a Subscription” or “Renew your subscription”. Why? It’s easier for people to know what they’re doing.

But the way, “for subscription only” could actually be for any feature that is displayed in-game but when you click it if you don’t have a subscription it prompts with “For Subscription Only”

  • Subscribe for PRICE/month :arrow_right: Nothing bad here, just to add also “FREQUENCY” because you can create a yearly subscription.

  • Button :arrow_right: must contain at least the subscription price. Since the button is one the first things to see (different color).

Yeah i’ll probably change this.

I was going to add this but I couldn’t find the right word. Thanks for telling me!

I feel like it doesn’t need to, as you also have to purchase a dev product that has a cooldown after.

I might add this though: Subscribe for :robux_light: PRICE / FREQUENCY.

Tell me if you want me to PM you the UI.

yw

As included in the main module, it automatically does this.

Yep, that’s way better. I might also add into my UI Subscribe for :robux_light: Price/Frequency

But the way, I will be adding also Support for Custom Subscription UIs in the full release.

1 Like

Does it take the robux out of their account? Or can they pick where it gets taken monthly or yearly?

It isn’t taken out of the account automatically (that’s not possible). If the subscription has expired when the player joins the game, they have to renew their subscription. If they don’t do so, they will lose the perks from the subscription.

Please put this module in a GitHub repository, letting people read the code and make pull requests. This module looks interesting.

1 Like

I like this resource. Especially the UI. Very cool.

Just note that roblox has a Subscription System for developers that in development right now. It could release at any time now.

1 Like

Zum Doppelten preis vom bäcker nebenan ist es möglich die Wohnung zu besichtigen

1 Like

Was ist das problem mit dem part realistisch und kontrolliert???

1 Like

Sure! I’m going to upload it.

Thanks!

I know, even if it releases I’ll continue to update this one, trying to make it better than Roblox’s

1 Like

When they purchase, it’s with Robux. But you’re the one who makes the subscriptions monthly or yearly.

If you make a UI so they can pick monthly and yearly, they will get a more customized subscription.

github module. If I have to enable something in GitHub so everyone can do Pull Requests, please let me know.

1 Like

Is it possible to make it where if they have Roblox premium they receive a month or a week free?

I’ll add it for the Free Trials when I release it!
Thanks for the suggestion!

1 Like