What is RunService.Stepped:Wait() being used for?

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

1 Like

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! :slight_smile:

4 Likes

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.

This is now redundant, use task.wait.

3 Likes

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