Roblox Wiki
Roblox Wiki
36,938
pages

The Task Scheduler is the internal scheduling system of the Roblox engine that is responsible for coordinating tasks, including processes of other internal systems such as input, networking, rendering, and physics. The scheduler also handles script execution and is responsible for API objects such as services and events to function properly. Tasks are coordinated by the scheduler according to the stepping of a frame.

The scheduler has its own API which can be accessed through the task library and Light service iconDark service iconRunService.

The built-in profiling tool MicroProfiler records information about Task Scheduler processes in real-time, which is accessed by pressing Ctrl + F6 or turning it on inside of the settings window.

Frames[]

The frame is a unit of game logic used by the scheduler to perform tasks each step. In game development, every task on a frame must performed efficiently for a faster frame rate (also measured in frames per second, or FPS). A frame is stepped when all tasks of the CPU and the GPU are finished.

On the client, physics run up to 240 hertz on fixed physics stepping, and dynamically fluctuate on adaptive physics stepping.

Although the engine running in Roblox Studio or the Roblox Player can run at any desirable amount of FPS, Roblox servers run at maximum of 60 FPS/60 hertz; however, physics can reach 240 hertz--and change dynamically when adaptive physics stepping is on.

API[]

task[]

The task library has functions allowing functions and threads to be scheduled with the Task Scheduler:

task.spawn(functionOrThread: function | thread, ...: Variant): thread
Calls/resumes a function/coroutine immediately through the scheduler.
task.defer(functionOrThread: function | thread, ...: Variant): thread
Calls/resumes a function/coroutine on the next resumption cycle.
task.delay(duration: number, functionOrThread: function | thread, ...: Variant): thread
Schedules a function/coroutine to be called/resumed on the next Heartbeat after the given duration (in seconds) has passed, without throttling.
task.wait(duration: number): number
Yields the current thread until the next Heartbeat in which the given duration (in seconds) has passed, without throttling.
task.cancel(thread: thread): void
Cancels a thread, preventing it from being resumed.

The task library also has functions relating to parallel Luau, which work only if run by a script in an Actor light iconActor dark iconActor:

task.desynchronize(): void
Switches the thread to parallel state (assigns it to a different worker).
task.synchronize(): void
Switches the thread to serial state (assigns it to the main thread).

RunService[]

The Light service iconDark service iconRunService houses events that fire every frame. The events are different from each other that they fire at different priorities. RenderStepped is fired first, then Stepped, and then Heartbeat. The RunService allows the client to bind functions to a render step with a specific priority using RunService:BindToRenderStep(), which are called before the RenderStepped event.

Third-party software[]

  • Bloxstrap, a bootstrap replacement for the traditional Roblox launcher, with extra capabilities (such as setting custom FPS caps).

External links[]