time
Monotonic seconds elapsed since the VM started.
Syntax
time() -> number
elapsedTime() -> number
Parameters
This function takes no parameters.
Returns
| Type | Description |
|---|---|
number | Seconds as a floating-point value. |
Description
Reads the same steady clock as tick, so the value never jumps backwards when the system clock changes.
Use it for measuring durations; os.clock reports CPU time instead, and os.time the wall-clock epoch.
elapsedTime() is an alias of time().
Example
local started = time()
task.wait(0.25)
print(time() - started)
Notes
time() - time()— Comparisons are safe across threads because the clock is shared by the whole VM.elapsedTime()— Alias oftime().