Questions on runService

I already know what runService does but I don’t really know when I should properly use it. I have so far only used it once and that is for my main menu camera rotating physics.

Can people give me good examples of when they possibly used it or what things should I honestly use it for? Like only for physics based things? i.e things that move? Or would cloning in parts from serverStorage within a for loop be considered to be used under runService (I would like to have this answered tbh).

Thanks for answering my question if you do.

A pretty easy example is just by looking at this website, It tells u exactly when Heartbeat is fired etc: Task Scheduler | Roblox Creator Documentation

That is true, however that is only a subset of what RunService can do.

The broader set is time management “RunService contains methods and events for time-management

You use anytime you want things to change with time. Roblox wise it could be Daily shop events, stopwatches, clocks, UI transparency effects, and physics as you discussed.

To elaborate further with daily shops it is because every frame there is a possibility that the shops will refresh and hence will need an event from Runservice to measure the time and know when to update the daily shop.

Does the for loop use task.wait() or wait()? If so then yes indirectly RunService is used to interact with the task scheduler as @BobbieTrooper has linked. task.wait() is the same as RunService .Heartbeat:Wait()

From documentation If no duration is given, it will default to zero (0). This means the thread resumes on the very next step, which is equivalent in behavior to RunService.Heartbeat:Wait()

RunService also houses events that allow your code to adhere to Roblox’s frame-by-frame loop, such as Stepped, Heartbeat and RenderStepped. Selecting the proper event to use for any case is important, so you should read Task Scheduler to make an informed decision.

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