Soflowsen
(Soflowsen)
August 31, 2021, 8:57pm
#1
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
D0RYU
(nici)
August 31, 2021, 9:14pm
#2
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.
D0RYU
(nici)
August 31, 2021, 9:17pm
#4
earthyviking92:
wait()
is old.
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.
D0RYU
(nici)
August 31, 2021, 9:18pm
#6
well no one is perfect, you will always learn new things
Soflowsen
(Soflowsen)
August 31, 2021, 9:19pm
#7
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.
D0RYU
(nici)
August 31, 2021, 9:21pm
#9
not exactly, I recommend looking at these two links to get a better understanding of the differences
Hey developers,
We have just enabled a brand new library that you can use in your projects. The task library allows you to talk directly with our engine’s task scheduler to manage and schedule code. It features a number of new methods as well as some improvements to existing methods.
Details
task.spawn
Takes a thread or function and resumes it immediately through the engine’s scheduler. Additional arguments are passed to the thread or function being resumed.
void task.spawn(function | thread,…
https://developer.roblox.com/en-us/api-reference/class/RunService
technically task.wait() messes with frames, but these are not the same thing
Soflowsen
(Soflowsen)
August 31, 2021, 9:22pm
#10
I did look at them, and it says.
1 Like
D0RYU
(nici)
August 31, 2021, 9:23pm
#11
yes, but they don’t do the exact same thing
task.wait() wouldn’t exist if they did the same thing
tob777
(Tob)
August 31, 2021, 9:24pm
#13
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
Soflowsen
(Soflowsen)
August 31, 2021, 9:24pm
#14
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
D0RYU
(nici)
August 31, 2021, 9:26pm
#16
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
D0RYU
(nici)
August 31, 2021, 9:28pm
#17
Heartbeat runs after Stepped
Stepped runs after RenderStepped
and RenderStepped runs first
1 Like
task.wait()
is a simple, more efficient way to do wait()
mainly.
Soflowsen
(Soflowsen)
August 31, 2021, 9:31pm
#19
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.
D0RYU
(nici)
August 31, 2021, 9:32pm
#20
if you don’t add any time argument into task.wait() then they are the same
EDIT: should have said this sooner, my bad
Soflowsen
(Soflowsen)
August 31, 2021, 9:34pm
#21
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?