Is task.wait broken?

Sdílet
Vložit
  • čas přidán 14. 05. 2024
  • Let's put our assumptions to the test!
  • Hry

Komentáře • 46

  • @sleitnick1
    @sleitnick1  Před 16 dny +2

    Some clarification:
    - The demonstration shows that `task.wait()` does exactly what it is supposed to do; our assumption that it always waits a frame is wrong.
    - As framerates are dynamic, there's no magic number to plug into `task.wait()` to wait 1 frame. You as the dev are responsible for understanding this behavior and acting accordingly.
    - I did not use the global `wait()` function because it is deprecated.

    • @Deniied
      @Deniied Před 16 dny +1

      Please do not expose the backdoor in the ROBLOX Source code.

  • @mogaming163
    @mogaming163 Před 17 dny +14

    🗣🔥WE MAKING IT OUT OF DOCUMENTATION WITH THIS ONE 🔥
    Already knew this but I'll be using this to explain it to others so thank you!

  • @aminaye1316
    @aminaye1316 Před 16 dny +3

    Watching this has given me a sudden urge to look at the Roblox engine functions and try to catch anything niche with them, adding more depth to my knowledge, i'd like to see more videos like this :)

  • @kylehickmen1684
    @kylehickmen1684 Před 16 dny +2

    parallel lua video in the works?

  • @crusherfire1
    @crusherfire1 Před 16 dny +5

    This was very neat! I enjoy these kinds of videos :)

  • @maxwell_edison
    @maxwell_edison Před 17 dny

    Crazy useful to know! Should be easy enough to workaround.

  • @BrawlDevRBLX
    @BrawlDevRBLX Před 16 dny +1

    Fascinating

  • @Mars-ws9cm
    @Mars-ws9cm Před 17 dny +9

    yay new video!

  • @MS-lb9yd
    @MS-lb9yd Před 16 dny

    What studio theme do u use?

  • @KashTheKingYT
    @KashTheKingYT Před 13 dny

    Very cool

  • @Curtis_11
    @Curtis_11 Před 17 dny +2

    Is there a particular reason why task.wait waits until the next heartbeat and not the next render step internally? What's the point of that minuscule difference if it's causing unintended behavior?

    • @binaryparrot3352
      @binaryparrot3352 Před 16 dny

      RenderStepped runs right before rendering the frame. The server does not render anything, thus never runs RenderStepped. Also slow running slow code in RenderStepled can significantly drop the frame rate.

    • @Curtis_11
      @Curtis_11 Před 16 dny

      @@binaryparrot3352 Ahh right, I see that now. Thanks

    • @wedoalittletrolling723
      @wedoalittletrolling723 Před 16 dny

      @@binaryparrot3352 I mean server can run RenderStepped in studio, but only in studio because of the server window you can switch to. Live games will never have this effectively making RenderStepped on the server useless

  • @clocky5018
    @clocky5018 Před 17 dny

    thanks!

  • @eliteengineer7340
    @eliteengineer7340 Před 16 dny +1

    I just dont use task.wait() without args, its ambious and doesnt make sense, if you want to wait a frame wait a frame

    • @wedoalittletrolling723
      @wedoalittletrolling723 Před 16 dny

      fr, or even just learn how to time events using delta time

    • @sleitnick1
      @sleitnick1  Před 16 dny +2

      I don't understand what you mean, "if you want to wait a frame wait a frame." That's exactly what I'm demonstrating doesn't work as expected. Even if you put `task.wait(0)` you will end up with the same thing. Frames vary in timing, so there's no secret number that waits 1 frame. You as a dev need to be conscious about your current invocation cycle to properly wait a frame.

    • @eliteengineer7340
      @eliteengineer7340 Před 16 dny

      @@sleitnick1 i mean , just runservice.renderstepped:wait() or heartbeat or whatever else you need. That way its more clear whats going on. task.wait might have a specific definition but it's not intuitive what it does.

    • @eliteengineer7340
      @eliteengineer7340 Před 16 dny +1

      @@sleitnick1 I mean that since task.wait() is so ambigous just use RunService.Heartbeat:Wait() or the other events, since they are more specific , it's more intuitive , you know exactly whats going on

  • @ZeroManYT
    @ZeroManYT Před 16 dny

    Could you not just do task.wait(1) in the instances where the time diffrences are the same , although i agree dose seem to be broke.

  • @yourcomputerhasdied
    @yourcomputerhasdied Před 17 dny +1

    task.wait() waits until a Heartbeat, and wait() doesn't
    The question is, what does wait() wait for?

    • @bacon_208
      @bacon_208 Před 17 dny +1

      task.wait() waits for the time given then heartbeat
      wait() waits for the time given and does other stuff you never asked it to do
      unless the joke is that you haven't provided an arg which in that case, it do be like that...

    • @littensy
      @littensy Před 17 dny +1

      wait() is based on an older 30hz system, and the minimum it will wait is 29ms!

    • @Focusluvyou
      @Focusluvyou Před 17 dny

      ​@@littensy source?

    • @radwl
      @radwl Před 16 dny

      wait() has some dark magic type of waiting that is meant to wait for like 30ms, but in reality it can wait as much as a minute, nobody knows why, but at some point in development your wait() will start to get slower and slower and can go up to tens of seconds of delay to each wait that you use

    • @koye4427
      @koye4427 Před 16 dny +1

      wait() uses an old, throttled system that may or may not resume execution after some time has passed

  • @StarJ3M
    @StarJ3M Před 17 dny +1

    hi guys

  • @HashCollision
    @HashCollision Před 17 dny

    Thanks for explaining all this, Sleitnick.

  • @minerssp4363
    @minerssp4363 Před 17 dny +3

    How is your life goin?

  • @ahmoin
    @ahmoin Před 16 dny

    task.wait(), what?

  • @miffclick3358
    @miffclick3358 Před 17 dny +3

    Stop click baiting.

    • @dimitar.bogdanov
      @dimitar.bogdanov Před 17 dny +13

      It’s not clickbait. Someone unfamiliar with the event cycle might be completely confused by this, as it _looks_ broken, but isn’t.

    • @sleitnick1
      @sleitnick1  Před 17 dny +16

      @@dimitar.bogdanov That's why I made this. I was quite confused at what was going on at first.

    • @bacon_208
      @bacon_208 Před 17 dny

      if someone wasn't aware that task.wait() runs at heartbeat or at least summarised it as every other frame (because that's usually the context in which task.wait() is used) then this video is pretty valuable and straight to the point as well
      definitely not click bait. The title is obv trying to grab your attention because that's how the algorithm is but it proposes a question instead of a statement so it's not wrong

    • @vyntax.mp3
      @vyntax.mp3 Před 16 dny

      ​@@sleitnick1ignore the OP. Ive seen this guy hate on other developer youtubers like crusherfire.