Check Time (Ask)

How to make a gamepass that only can be used until 00:00 of the next day that the person buy.
So if the player buy today at 15:00 it’s active for 9 hours and if other player buy at 14:00 it’s active for 10 hours (14:00-00:00)

If you want this form of interaction it would be better to use Devproducts over Gamepasses as gamepasses can be bought via game page. You will need to make use of this post to figure out the current time.
Then you just need to os.time() when they purchase and have the total amount of seconds for how long the effect lasts. 32400 Seconds == 9 hours , You would save os.time() in data on when player purchased and compare it to os.time() on a check to see how much time has passed every second, If it exceeds an amount of seconds then you would want to get rid of "active"

I’m not exactly sure what you mean by “can be used until” which is why I recommended using Devproducts instead since you can make use of the current time and essentially hide the purchase option and disable it once it elapses that Local/Global time

1 Like

So I saw many tutorials but it lasts for 24 hours, but I want to make that the player’s gamepass effect can only be active until 00:00 the next day, so no matter at what time they buy. Like If i buy at 15:00 I can only get the gamepass’ effect for 9 hours, but let’s say you buy it sooner, like at 12:00 you will get the effect for 12 hours, because it’s 12 hours for you to 00:00 the next day and only 9 hours for me because I bought it at 15:00. So it’s not depends on seconds that you set on script by like using local seconds = 86400.

Then all you would need to do is store the number for the current Day num
And every second check to see if the current Day number has changed, if it has then this effect is no longer valid. You will also need to keep in mind for Month and Year as well if this is something you want to constantly happen every day. TLDR: store year month day, if year month day ~= the year month day of purchase then a new day has begun meaning 00:00 was passed


Link to OS Docs