I was looking through code from an OS file i had and found this:
function gWait(Time)
local TimeElapsed = 0
while TimeElapsed < Time do
local _,dt = RunService.Stepped:Wait()
TimeElapsed += dt
end
end
being used as a replacement for a regular task.wait(), is there something about this code that would make it more efficient? For context this file is a vfx demo so im guessing something visually would benefit from this being here
task.wait() is the same as RunService.Heartbeat:Wait(). RunService.Stepped:Wait() is not exactly the same although it would look identical in most cases
For more information about these RunService functions, you can visit this topic: RenderStepped, Stepped, or Heartbeat - #2 by rogchamp
Hope it helps!
The behavior should be almost identitcal to that of task.wait, if this is an excerpt from older code this may have been used before the task library was added, like how people made their own version of task.spawn with BindableEvents.