so i’ve created a timer module in an attempt to sort of familiarize myself with the concepts of object-oriented programming. it was initially created for personal use, but i’ve decided to make it public.
the goods:
(1) Ultimax’s Timer Module - Roblox
well, now that you have my timer module, how do you use it?
the methods
-
CreateTimer
: creates a new timer instance with a given name and callback function. the timer is stored in a “timers” table. -
Start
: initiates the timer with a specified duration in seconds. the timer counts down, and when it reaches 0, it invokes the callback function. -
Pause
: pauses the timer by disconnecting from theRunService.Heartbeat
event. -
Unpause
: resumes a paused timer. -
Stop
: stops the timer, disconnects from the heartbeat event, and resets its properties. -
GetTimers
: returns a table of active timers. -
GetTimer
: returns a specific timer instance by name.
an advantage my timer module has is that callback functions can be provided when creating a timer to specify actions to be performed when the timer reaches 0.
in order to use the module, you can create timers using “CreateTimer” , start them with “Start” , pause and resume with “Pause” and “Unpause” , and stop them with “Stop” .
DISCLAIMER: my timer module uses RunService for timing, and the precision of timers may be affected by the frame rate
honest feedback is appreciated, as this is my first real resource on the dev forum!