When does game:GetService("RunService").Heartbeat/RenderStepped gets fired? And when to use it?

I’ve always wondered, when does game:GetService(“RunService”).Heartbeat/RenderStepped gets fired? And when to use it?

Should you always use one of these to replace wait()? (If you were to use a while true do loop, for example.)

Edit: I should’ve done some search, I just done it now, and I just found a topic almost the same thing I’m looking to know…

RenderStepped fires before a frame, Heartbeat fires during a frame.

It’s best to use these when you need extreme precision, ex: updating something in-line with the camera, a custom wait function, etc.

I wouldn’t recommend using these to completely replace wait() in a loop as running something every frame is inherently intensive, but using something like an aforementioned custom wait function with a default of 0.03 would be more reliable than flat out using wait()

1 Like

RenderStepped is fired every render frame, Heartbeat runs after every physics update. Additionally, Stepped fires before a physics update. Custom wait solutions have been made using these events yes. I will go ahead and leave you this as to why people might go for a custom wait solution:

https://eryn.io/gist/3db84579866c099cdd5bb2ff37947cec

1 Like