Task.wait() for stepped

Task.wait() is a replacement for RunService:Heartbeat(), right?

What about stepped, is there a replacement for that one?

I don’t understand the task scheduler much, so I don’t know what stepped means, I do know that it comes before heartbeat, and comes before physics is calculated, not sure what that means tho.

1 Like

no, it replaces wait()

Heartbeat, Stepped, and RenderStepped are not being replaced

1 Like

wait() is old. Everyone uses task.wait(). @D0RYU had to teach me this as well lol.

didn’t wait() first come out when lua was originally released?

Yeah, I guess so. All my tutorial videos used wait() so I learned bad habits.

well no one is perfect, you will always learn new things

Is it equivalent to RunService.Heartbeat:Wait()?

edit: Also, what if I check physics and affect physics in on script, should I use heartbeat or stepped?

No. task.wait() is equivalent to wait(). That’s what me and @D0RYU just said.

not exactly, I recommend looking at these two links to get a better understanding of the differences

https://developer.roblox.com/en-us/api-reference/class/RunService

technically task.wait() messes with frames, but these are not the same thing

I did look at them, and it says.

1 Like

yes, but they don’t do the exact same thing
task.wait() wouldn’t exist if they did the same thing

As far as I know there is currently no actual replacement for a Stepped wait. You’d have to write your own. Here’s an example on how to do that

local function steppedWait(t)
    local start = os.clock()
    while os.clock() - start < t do
        game:GetService("RunService").Stepped:Wait()
    end
    return os.clock() - start
end

I know that they return different delta time, what other differences are there?

task.wait() is a lot easier to write, that’s one thing for sure lol.

1 Like

well for starters
task.wait() has a time parameter
Heartbeat can be made into a connection so :Wait() works

you use them for different things

you couldn’t do Heartbeat:Wait(5) like you can with task.wait(5)

1 Like

Heartbeat runs after Stepped
Stepped runs after RenderStepped
and RenderStepped runs first

image

1 Like

task.wait() is a simple, more efficient way to do wait() mainly.

This is different though.

Heartbeat:Connect() is different too

What I’m saying is, is task.wait() the same as Heartbeat:Wait()?

Without any parameters and excluding the different delta times.

if you don’t add any time argument into task.wait() then they are the same

EDIT: should have said this sooner, my bad

So, I connect heartbeat if I check physics, and connect stepped if I affect physics?

What if I check and affect physics in one function, what do I connect?