Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
Task scheduler
The task scheduler coordinates tasks done each frame as the game runs, even when it is paused. These tasks include detecting player input, animating characters, updating the physics simulation, and resuming scripts in a task.wait() state.
While there may be multiple tasks running, the task scheduler can potentially be overloaded, especially in the following situations:
- Using a custom character rig or input scheme.
- Animating parts yourself (instead of using an
Animator). - Depending heavily on precise physics.
- Replicating objects regularly.
RunService
The most direct way to add frame-by-frame tasks is through the following members of RunService:
RunService.PreAnimationRunService.PreSimulationRunService.PostSimulationRunService.HeartbeatRunService:BindToRenderStep()RunService.PreRender
Scheduler priority
The task scheduler categorizes and completes tasks in the following order. Some tasks may not perform work in a frame, while others may run multiple times.
* Script execution during RunService.Heartbeat differs depending on your game's Workspace.SignalBehavior setting. See Deferred events.
Best practices
To build performant games with efficiency in mind, note the following:
Don't connect/bind functions to the render step unless absolutely necessary. Only tasks that must be done after input but before rendering should be done in such a way, like camera movement. For strict control over order, use
BindToRenderStep()instead ofPreRender.Manage physical states carefully.
PreSimulationhappens before physics, whilePostSimulationhappens after physics. Therefore, gameplay logic that affects the physics state should be done inPreSimulation, such as setting theVelocityof parts. In contrast, gameplay logic that relies on or reacts to the physics state should be handled inPostSimulation, such as reading thePositionof parts to detect when they enter defined zones.Motor6D transform changes should be done on the PreSimulation event. If you don't,
Animatorswill overwrite changes on the next frame. Even without anAnimator,PreSimulationis the last Luau event fired beforeMotor6D.Transformis applied to part positions.