Run Service Details

I have been using RunService.Heartbeat instead of while loops for a long time now, but I never really understood the difference. I took a look at the Developer Hub to check out the description and noticed that RunService has a lot more than just heartbeat.

  • while do
  • RunService.Heartbeat
  • RunService.Stepped
  • RunService.RenderStepped

What is the difference?
And what are some examples of when one should be used over the others?

While do is basically just an infinite loop.
RunService.Heartbeat is an event that fires every time after a physics simulation was completed (in a frame i believe)
RunService.Stepped is an event that fires every time a physics simulation is about to begin
RunService.RenderStepped is an event that fires every time a new frame is about to render

1 Like

How would knowing the difference between these things help in real-life application?

From my experience.

RenderStepped is for camera CFraming related otherwise you will encounter camera delays for example with viewmodels.

.Stepped is for Motor6D .Transform animation overwriting due to the run order.

Stepped is also recommended for physics like VectorForces or velocity although personally I did not notice a difference between heartbeat and stepped (needs a test).

My summary of the task scheduler documentation related to RunService.

Also while do is the same as Heartbeat if you use task.wait() from the task documentation.

1 Like

Well I have mainly been using Runservice:BindToRenderStep() because priority a is before 2, and also because I can run somthing before the camera and input or after input and before camera. and physics crap also RenderPriorities

But according to Task Scheduler | Roblox Creator Documentation

Order is

BindToRenderStep has priorities which is here RenderPriority | Roblox Creator Documentation
RenderStepped and BindToRenderStepped are running during the frame before screen drawing, and Stepped and Heartbeat are after the frame is rendered which is why You dont want to use them if you dont want to be 1 frame behind.

But Stepped should be called to update Motor6Ds.
Heartbeat is the almost the last thing called and After the frame is rendered.

1 Like