Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can someone Explain Runservice BindTorenderStepped, and Heartbeat and Stepped?

I really want to lean run service rn.What can I do with these three (3) methids

:BindToRenderStep

.Heartbeat

 and

Stepped

can someone explain plz. How can I use it in my scripts? Like my sword scripts

7 comments

0

I don't think you'll need run service for a sword script

0

are you sure?

0

I don't think you'll need to run something every 1/40th of a second for a sword script

0

1/40 of a second? uh do you mean frames?

0

thats 0.025 seconds

0

ohoho whoa thats fast!

0

also HeartBeat fires every frame

1 answer

✓ Accepted answer

Let me just say that you do not need this for a sword script.

To start off, Roblox obviously runs in frames, a "healthy" Roblox server will run at approximately 60FPS (It can be lower in laggy servers). Each frame everything is recalculated and rendered, for example every frame the physics engine updates an objects position based on factors like gravity. Every frame the visible portion of the game is redrawn onto your screen. Both RunService.Stepped and RunService.Heartbeat are events linked to this behavior. Stepped fires code right before a new frame is drawn. This is useful for code that will visually change the game. RunService.Heartbeat is fired right after each frame is drawn, so it's not a good idea to have visual changes connected to this. And :BindToRenderStep() is very similar to RunService.Stepped except it allows you to set a priority for the code that's connected to it to execute. When .Stepped is fired there is no way to to guarantee that all of the code fires at the same time or in any order. With :BindToRenderStep() You can make sure that all code on a certain priority fires at the same time and before lower priorities.

RunService.Stepped is useful for updating the position of an object every frame RunService.Heartbeat is useful for making fast loops that don't affect the visual aspect of a game, such as changing values quickly.

For more information on these, please look at the Developer Hub, specifically: :BindToRenderStep(), RunService.Stepped and RunService.Heartbeat

I hope my answer could solve your problem. If you felt it was the best, please don't forget to mark it correct!

This discussion is preserved as it was. New answers, comments, and votes are closed.