boyparis
(B0re4li5)
May 27, 2021, 4:46pm
#1
I’ve recently had a couple of people tell me that using while true do is not a good idea, but i also feel like renderstepped is not always the most favorable option of the two.
I’ll just copy and paste my response from a similar topic:
RunService doesn’t create ‘loops.’ The things you listed are events that are fired at certain points during runtime giving the illusion of a loop. Each event fires at specific points:
Heartbeat fires after Physics are simulated (end of the frame)
Stepped fires during physics simulation (middle of the frame)
RenderStepped fires before physics are simulated (start of the frame)
For example, you should use RunService.RenderStepped or RunService:BindToRenderStepped() for a custom camera system be…
2 Likes
Doqee
(Doqee)
May 27, 2021, 4:50pm
#3
while true do wait()
basically loops every 0.03
seconds, whereas RenderStepped
runs every frame.
please never use wait()
, especially in loops.
boyparis
(B0re4li5)
May 27, 2021, 5:09pm
#5
why though, how else am i going to add a delay between stuff?
This is an adaptation of a Twitter thread I made a while ago. This is simply a better formatted and more fleshed out version.
Let’s talk about wait(). Not wait(n) (although if you are using small n values to where it’d be barely distinguishable from wait(), you’re probably going to hit the same issues mentioned in this thread).
We probably learned about wait() at first as the solution to “why are my infinite loops crashing me?”. It’s a super easy solution and it works! This starts a bad habit…
I would suggest using a heatbeat or renderstepped wait function. wait()
is slow and inconsistent and is a major source of lag.
D0RYU
(nici)
May 27, 2021, 5:15pm
#7
just realized they said runservice loops
they are not loops
boyparis
(B0re4li5)
May 27, 2021, 6:00pm
#8
oh ok, I just realised you meant wait() with no parameters.