Do you care about what to use in runservice

do you guus care if ur script uses heartbeat or rendestep or stepped because if they are this important im haveing a hard time to understand especially thr physic simulation and how tasks like task.wait is related to it

yes
each one will run after/before a specific action in the frame

i recommend this video if you are trying to learn them
there are a few wrong things in the video so check the first commend

i ve watched it before but the physic simulation and task.scheulder seems too complicated for me thats what i want to know here

1 Like

that is just an example of the task.scheulder the order/processes may not be correct
there are many processes done each frame and Run Service let you decide when do you want your code to execute for example do you want to execute your code before rendering? or do you want to execute it after physics? etc…

Frame1

– render stepped will run here
1- render the game

– stepped will run here
3-handle the physics – this is physics simulation
– heartbeat will run here

Frame 2

etc…


i amnot good at explaining idk if this is clear

the same as the video maker has said what i want to know is how can for example runservice run before or after task.wait() or what is physics here

what does that mean? can you show an example?
task.wait() isnot a main process in the task.scheulder

physics is physics
when u make an unanchored part and push it with your character it will get moved (that is physics)
or when you jump with your character you will fall after jumping (that is physics)

just like how the real world have physics roblox studio have physics that is being calculated every frame

image
look at the picture there is task.wait before heartbeat
i really need examples or one to understand how pyhsics simulation work
besides this ordered list what do we call it ?

1 Like

you canot do that run service can only execute scripts before/after physics simulations or rendering

basically every frame roblox will calculate physics,
physics are like a moving object / unanchored part failing from the sky / etc…

physics is made by roblox into the engine and every frame they calculate the physics simulation

physics simulations is just real world physics made into roblox and its done already you can just think about it as physics


if you are talking about how they made the physics it is very advanced and requires alot of math

I don’t know if this is what you want answered, but I’ve had questions similar to this, so I’ll try my best. I’ll basically give you use cases of each.

RunService.Heartbeat VS Task.Wait

They can actually be quite similar as task.wait waits exactly one heartbeat which is the same as RunService.Heartbeat:Wait()

This is after the physics have been calculated, so let’s say a part moved, the game would calculate that and then immediately after that is heartbeat.

So now, what’s before the physics?

RunService.Stepped

Stepped is what happens right before the physics simulation has begun, so think about it like this:

RunService.Stepped → Physics Simulation → RunService.Heartbeat (task.wait)

RunService.RenderStepped

This is BEFORE the frame is even rendered.

So before anything has even happened on the screen, this will run.

Now, let’s get into the use cases of each.

Use Cases

Heartbeat:
You’ll want to use heartbeat if you are reacting to a change in physics, or if you want something to happen every frame.

Stepped:
Now this is almost EXCLUSIVELY used when you want to change some part of the physics every frame. If you just want something to happen every frame, then use heartbeat.

RenderStepped:
This is pretty much only used when you want to adjust the camera every frame, or do something with the character every frame.

I know these weren’t the best examples, but I tried.

1 Like

thanks for the help but i don’t want to memorize when to use what. i want to understand why would use this instead of that or what would happen if i don’t use the right runservice ect…

If that’s all your looking for (and I hope I understood you right again), then the simple answer is that your game is not going to crash if you accidentally used heartbeat instead of stepped, and your game would run just as fine.

This stuff is running every frame, so the timing isn’t going to kill you.

The one thing that might get you into some trouble is overusing RenderStepped, and the reason because of that is b/c the frames are rendered SEPERATELY from the game’s physics, but that’s not something to worry about.

Just as a general rule of thumb:

Heartbeat for almost everything,
Stepped for changing physics
RenderStepped for changing camera.

2 Likes

well i guess i have to memorize without understanding then :smiling_face_with_tear:

@HeCatchThose is the textbook definition.

I would add more info and visualization for heartbeat vs stepped only matters if you are running complex physics calculation like physics substepping.

If you don’t use it right the calculations get messed up and you end up applying the forces a frame late or using the incorrect position/velocity values needed for a calculate calculation since it happened a frame before instead of the current frame.

Using heartbeat:

Using stepped:

1 Like

if u have made this for me then i really apperciate it but i dont understand something … what is the difference in those 2 vids ?

Yep I made it for you as well as for own curiosity as there is a lack of examples on what happens if you use heartbeat instead of stepped for physics.

The difference is that I just replaced the .Stepped connection with .Heartbeat.

For context the algorithm makes physics stable at lower fps.

Using .Heartbeat it doesn’t work and flips.

Using .Stepped makes it work as normal and stays upright.

1 Like

i didnt relaise anythin about smoothness all i was careing about is the behavior about the table lol( but i sill dont see the difference though)

1 Like

i think the change of a character’s position would suit stepped right?

Yes, since stepped is most suitable for changing physics.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.