So basically I'm making a membership system in my game. The membership that I made is called VIP. It's not a gamepass it is a developer product which means it can be purchased multiple times. The reason I made it a developer product is because of I want it to expire depending on what the players have bought. I made 3 subscriptions and those are VIP for 15 days, VIP for 1 month and VIP forever. I got the idea from Pet Simulator 2, where you can subscribe for 2 hours, 3 days, and forever. I got inspired by it. Can someone please help me implement it to my game? I would totally appreciate it if you would help me make it.
How to make a membership that can expire depending on what the player had bought?
1 answer
Membership time decreases even when player is offline
You would need to use a mix of os.time(), DataStores, and the MarketplaceService in order to do this.
Read more about os.time() here.
To elaborate, os.time() gets the current seconds since January 1st, 1970. A day is 86400 seconds, so if you wanted to get when it should expire, you could do os.time() + the amount of time you want the player to have it. Constantly checking if the os.time() equals the expiration date, you could make it work.
You'd also need to use DataStores to save the expiration date. Read more here.
Membership time doesn't decrease if player is offline
This is a lot simpler. Make a value and set it to the amount of seconds the player should have membership. You can then decrease that by 1 every 1 second. You should also save the amount of time the player has left with DataStores.
2 comments
Wow, I thought it was easy to make! Anyways thanks for giving me that information!
No problem. If you know what you are doing, it can be pretty easy.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Use tick() combined with the Data Persistence API, and MarketplaceService.