Timer
Timer, Stopwatch and Duration objects driven by the VM scheduler.
Creates a repeating timer. Configure Interval, RepetitionCount and OnElapsed, then set Enabled to true.
local timer = Timer.new()
timer.Interval = 1
timer.RepetitionCount = 3
timer.OnElapsed:Connect(function()
print("tick")
end)
timer.Enabled = true
Creates a stopwatch object with Start, Stop and Reset methods.
local stopwatch = Stopwatch.new()
stopwatch:Start()
Starts or resumes the stopwatch.
local stopwatch = Stopwatch.new()
stopwatch:Start()
Stops the stopwatch and adds the elapsed time.
local stopwatch = Stopwatch.new()
stopwatch:Start()
stopwatch:Stop()
Stops the stopwatch and clears its elapsed time.
local stopwatch = Stopwatch.new()
stopwatch:Reset()
Creates a Duration from nanoseconds.
local duration = Duration.FromNanoseconds(500000000)
print(duration.Seconds)
Creates a Duration from microseconds.
local duration = Duration.FromMicroseconds(500000)
print(duration.Seconds)
Creates a Duration from milliseconds.
local duration = Duration.FromMilliseconds(500)
print(duration.Seconds)
Creates a Duration from seconds.
local duration = Duration.FromSeconds(2)
print(duration.Milliseconds)
Creates a Duration from minutes.
local duration = Duration.FromMinutes(2)
print(duration.Seconds)
Creates a Duration from hours.
local duration = Duration.FromHours(1)
print(duration.Minutes)
Creates a Duration from days.
local duration = Duration.FromDays(1)
print(duration.Hours)
Creates a Duration from months.
local duration = Duration.FromMonths(1)
print(duration.Days)
Creates a Duration from years.
local duration = Duration.FromYears(1)
print(duration.Days)
Creates a Duration representing the time since the Unix epoch.
local duration = Duration.TimeSinceEpoch()
print(duration.Seconds)