How to make a script work even when there is no player?

  1. What do you want to achieve?
    I want my script that sets the date and time to continue to work even if no one is connected to the game !
  2. What is the issue?
    The time and date are reset!
  3. What solutions have you tried so far?
    I don’t know already how to do this …
3 Likes

When u put time and date did u pet = (True) that might work.
However I am not a coder of that stuff so I am not to sure but good luck!

1 Like

It is impossible I think really. When there is no one inside of a game then it means there is no servers running so you could not do it directly from Roblox.

Although you can’t do it directly from Roblox you could use a web server and like do stuff like storing stuff in a database from outside of roblox in a server.

1 Like

I didn’t quite understand what you just told me, but thank you for the answer! :sweat_smile:

1 Like

Oh too bad but are you sure there is no way? :thinking::disappointed_relieved:

Try this: os time.
Returns the Epoch time since Jan. 1, 1970.
In other words, real world time.

3 Likes

The issue with that is as stated by the user they want the script to work when there is no player inside of the game which from my knowledge cannot be done cuz if there is no one inside of the game the servers shut down so it can’t run the script.

1 Like

Well how the script run? If there is no server running cuz all the player are not in the game then no scripts will run.

Like I said in my post your best luck would be to use some type of web server outside of roblox which deals with the time.

1 Like

That time is not based on Roblox at all. It’s real world time.

2 Likes

I know I am not stupid lol.

What I mean is that the user has stated that they want the “date and time to continue to work even if no one is connected to the game” but the issue is that if there is no players in-game there is no servers open for the script to run.

Yes OS time would work to get the time however it does not fix the issue the user has with how to make the script runs even when there is no player in the server.

1 Like

You will have to make your time dynamically save when a server turns off. I think you are assuming that when you leave the game, the server stays up like front-paged games do. That is not the case, those servers stay up because at least one player is connected most of the time. When you leave your small game, the server will think “hmmmm, there is no one here, I better shut off” so another game can use the slot.

@LifeDigger was perfectly correct

1 Like

Yes, but here’s the thing.
@FireStrykerAzul asked for his script to read ‘time’ even when the game isn’t running.
If he uses a script that references os.time that doesn’t reference the user’s computer, or Server time on Roblox, it is calculated from 1970 and is always referenced to that time.
If a player opens a new server then os.time is going to be accounteded for so you the time and date won’t be reset…

If for example they want to calculate how much total time a player has played then they would only need to save their data depending on when they start a server and leave a server, which would be os.difftime(start time, leave time)

1 Like

Yes I agree but I don’t need the real time I created my own variables … :thinking::sweat_smile:

Thats a good point I did not think of that.

1 Like

But you can use the os.time to figure out the that has passed since it was started.
Say you started your time at Mar. 1, 2022. You’d calculate that number of seconds and subtract it from os.time to get your starting point.

Or if your time frame is “a day is 13.56 ooblongs” you could convert your number with a simple formula to seconds, and base your “ooblong” timespan on os.time.

1 Like

Probably won’t work, but you could try using datastores.