What's the difference from RenderStepped, Stepped, and Heartbeat?

Hello,

I’m wondering about the differences between these three Run Service events, when to use them, and which one is the best to use.

1 Like

Here is the answer to a good post almost exactly like this one you can look at

3 Likes

Stepped is an implementation that will run every frame. It is very similar to RenderStepped, but uses older technology and works on the server as well. It also includes a time parameter which will determine the amount of time since the game started.

Heartbeat will run after every frame but after the physics simulation completes. It’s usually used to make modifications to the physics such as moving a part or changing the CFrame. Usually, you wouldn’t want to put a very unoptimized function here as it will significantly decrease performance.

RenderStepped will run every frame before any rendering. It should be used for tasks that apply to the camera or character since it does not run in parallel to the rendering tasks Roblox performs, thus can lead to lag. This would look like a delay since this task will delay the task of the frame being rendered. It runs at a variable frequency depending on the framerate of the client. You should be using this for the camera or character, but usually custom camera systems are a better choice.

BindToRenderStep is a function that will bind a function to RenderStepped but at a priority. See the creator documentation for more details.


task.wait is an alternative to RenderStepped or Stepped, but it shouldn’t be used instead as it is not guaranteed to run every frame. It appears to run at 60 Hz.

wait will delay the next line by a certain amount of seconds in 30 Hz.

Update: also in some cases, wait is better than task.wait because of its ability to throttle the game, thus reducing load on the server.

Here is a comparison of task.wait and wait:
image

11 Likes