This is a Heartbeat-free timer module utilizing roblox task scheduler to it’s fullest to accurately tick on a set interval. This module comes with GoodSignal as the signal library.
This is an experimental project to see what’s possible without heartbeat. It’s not meant to be used in production. If you like the api and don’t want to switch to another module you can use the production ready version which uses heartbeat. Download
WARNING: This module is not designed for frame-perfect precision, or a tight loop. It can always be ±1 frame off because how unpredictable task scheduler is. If you want a frame-perfect timer use RBX Util - Timer by @Sleitnick.
TimerExample.lua
local timer = Timer.new(1) -- 1 second interval
timer:Start()
timer.Tick:Connect(function(tick_count)
print("TickCount:", tick_count)
end)
CountdownExample.lua
local timer = Timer.new(1) -- 1 second interval
timer:Start()
timer:SetCountdown(10) -- Countdown from 10 to 0
timer.Tick:Connect(function(countdown)
print("Countdown:", countdown)
end)
timer.Ended:Once(function()
print("Timer Ended")
end)
--Constructor
Timer.new(interval_seconds: number): Timer
--Timer functions
Timer:Start(tick_instantly: boolean?)
Timer:StartCountdown(start: number, end_: number?, step: number?)
Timer:Stop()
Timer:Destroy()
--Setters
Timer:SetInterval(interval_seconds: number)
Timer:SetCountdown(start: number, end_: number?, step: number?)
TIP: Use SetCountdown to reset a timer.
TIP: Stop is same as Pause. A stopped timer can be resumed from where it left off.
1.21
- Made module public
1.22
- Fixed “Unable to start timer again on the same frame it ends.” Found by @keklol0401010101010
1.23
- Timer now ticks right after starting a new countdown if the previous countdown is still running
1.24
- Added
:StartCountdowna function that sets a countdown and starts the timer