Os.date seems to be hanging my server on launch/start

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Use os.date in a script to periodically check for date change
  2. What is the issue? Include screenshots / videos if possible!
    using os.date as specified seems to hang my game server startup (but not in Studio)
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I think I have found a solution by just using a new variable, just wondering why it would hang using this method.

First I use os.date as follows to create a date key:

local dateTable = os.date("*t", os.time())
local datekey = "Y"..dateTable["year"].."M"..dateTable["month"].."D"..dateTable["day"]

Later in the script, I try to update the existing dateTable variable with the new clock time(to make a new key and compare with the first one):

dateTable = os.date("*t", os.time())
local newdatekey = "Y"..dateTable["year"].."M"..dateTable["month"].."D"..dateTable["day"]

This seems to hang the server during launch, it doesn’t affect Studio or throw an error. It eventually starts but takes maybe 5 minutes to spin up the server and get the first player in. Using a new variable(local newdateTable) to generate the new date key seems to have fixed the hang problem.

This doesn’t seem like this script’s problem. Check for hangs in other scripts.

Yes, I think you are right, pretty sure it was just Roblox in general under heavy load and causing my game loads to be painfully slow. I guess it was a fluke when I changed that and it loaded fast. Because later it seemed to be hanging again, pretty much all day, then it got better in the evening. I tried to delete this topic but It won’t let me. Case closed.

We are not done here :joy:, open up script performance tab before running the game and then run the game to see if a script is occupying way too much ram.