Subscription based dev product

The idea

I am making a game where you can buy a subscription based dev product. The user clicks on either 3 months, 6 months or 12 months

The problem

I am currently stuck on how to remove the product from the user.

What I could try

A game-pass.

Making sure it’s not a scam

Have text saying you will be messaged a few days before it expires.

Ideas I have tried

I was thinking of maybe removing it from their inventory, but I don’t think that is possible.

:slight_smile: Thanks for reading!

1 Like

You could do a simple time-based system.

A user buys a 3 month product, 3 months gets added to their timer.

They then buy another 3 month product, their timer gets bumped to 6 months, etc.

Save expire date to datastore and when the date in datastore will be offdate, just remove the line and dont give him the dev product bonus.

I’m sorry but I’m a bit of a noob at scripting right now… Could you explain how I could make a timer?

Use the os library when you’re working with time-based purchases. Create a future timestamp to determine how long the product should last for. Assuming the subscription time is still valid even when the player isn’t in the game, your work is really easy.

If you’re using os.time, convert a future time stamp into seconds. You can do this by either doing a literal convert via an online resource (e.g. Google’s time calculator) or have your script evaluate it. Your calculation should be about 60*60*24*7*4*3 (60s, 60m, 24h, 7d, 4w, 3mo) (?). Afterward, add this value to os.time (os.time() + future time) and then save that. From here, just check if os.time is less than the saved value. If it is, keep the effects active. If not, deactivate them.

With os.date, it returns a table of information about the current date, including month. You will need to account for year spill-overs (12 + 3 = 15, not a valid month). The concept is still the same as with os.time, set a date in the future and then check the relation between the current date and that future date.

3 Likes

I am still confused.
Couldn’t the player change their pc time.

How would I set a timer so that when it expires the product is removed?

  1. How would I remove the product

  2. How would I tell the player it’s expiring soon?

That’s why you call it on the server. The client is irrelevant in this scenario and it should not be authoritative of any part of this system except informing the server that it wants to make a purchase (handled by the backend).

I just told you how to tell the time between now and 3 months in the future. If you want to inform the player of the time left (and in order to vreate a timer), send the time difference between the future time stamp and the current time to the client, then have it format and animate the countdown.

You can’t remove Developer Products. As for removing subscriptions, don’t - not unless it’s for a good reason. Player purchases need to be honoured, so if they buy it, they should retain that subscription for its full duration.

Yes but when the subscription runs out, what would I do?

Do nothing.

If you track time in an active subscription or or the like, you can call RemoveAsync on it to clear it out of the DataStore, though that’s not particularly necessary.

If you have a time-less-than check, only activate effects when the current time is less than the future time. By nature of this, no effects will occur when the current time is greater than the future time.

1 Like