Which one would I be using if I was trying to do something like an hour cooldown? How exactly would I go about doing this as well?
Thanks for any help/suggestions.
os.time()
and tick()
are almost the same, os.time()
returns the UNIX Epoch time, which is the time since:
Unix time (also known as POSIX time or UNIX Epoch time) is a system for describing a point in time. It is the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.
The main difference between them is that tick()
returns local time and may vary from server to server, os.time()
is best used to calculate differences in time out of a single server.
How would you use this to set a cooldown?
Simple, take the difference between os.time()
at two points in time. We can use a variable to store the first point in time then subtract it with the current point in time.
-- Time when script first runs local oldTime = os.time() -- example: returns 1000000 (for simplicity) -- Note: There are other ways to do this but a simple while loop could explain this pretty well. while true do local currentTime = os.time() if currentTime - oldTime >= 3600 then -- check if the difference is greater than or equal to 3600 seconds (1 hour) print("TIME IS UP!!") end wait() -- don't forget this end
I'm not sure what kind of cooldown you were looking for, the above example is definitely not practical so if you could specify a certain situation I might be able to help further.
Also, usually a wait(seconds)
would do for a simple cooldown.