Just now, I tried to use both wait() and task.wait() inside of a RunService.RenderStepped event.
I’m asking this because I transferred the code into a while loop and now the wait() yields it as it should.
Just now, I tried to use both wait() and task.wait() inside of a RunService.RenderStepped event.
I’m asking this because I transferred the code into a while loop and now the wait() yields it as it should.
No, outside the Connection, yes it will ignore those, but inside, it would be firing the code given after Rendering which it wont ignore.
However Connections do not yield when they fire
You wont notice that wait()
or task.wait()
is being used because its firing the code so fast.
its like this, I have this piece of code:
function hi()
task.wait(1)
print"E"
task.wait(1)
print"A"
end
if I fire it, it yields and fires the code inside which should only print once for each, But if it fired this 10 times at the exact same time without it being yielded (like with a connection, or a thread), It would print these at the same time because i executed the code at that same time.
All RenderStepped does is connect a multitude of callback functions to run BEFORE the next frame is rendered. you won’t “slow down” frame updates by including yields inside of your callback, but use it responsibly, as code which runs at a speed of approximately 1/60th of a second should be very optimized and memory-efficient to avoid poor performance.
Thanks for correcting.
Thanks for clearing that up! I was really confused as to why it wasn’t working.
Now I know something new about Luau, thanks!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.