Is task.wait broken?

Поділитися
Вставка
  • Опубліковано 14 тра 2024
  • Let's put our assumptions to the test!
  • Ігри

КОМЕНТАРІ • 46

  • @sleitnick1
    @sleitnick1  17 днів тому +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 17 днів тому +1

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

  • @mogaming163
    @mogaming163 17 днів тому +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 17 днів тому +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 17 днів тому +2

    parallel lua video in the works?

  • @crusherfire1
    @crusherfire1 17 днів тому +5

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

  • @maxwell_edison
    @maxwell_edison 17 днів тому

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

  • @BrawlDevRBLX
    @BrawlDevRBLX 17 днів тому +1

    Fascinating

  • @Mars-ws9cm
    @Mars-ws9cm 18 днів тому +9

    yay new video!

  • @MS-lb9yd
    @MS-lb9yd 17 днів тому

    What studio theme do u use?

  • @KashTheKingYT
    @KashTheKingYT 13 днів тому

    Very cool

  • @Curtis_11
    @Curtis_11 17 днів тому +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 17 днів тому

      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 17 днів тому

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

    • @wedoalittletrolling723
      @wedoalittletrolling723 17 днів тому

      @@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 18 днів тому

    thanks!

  • @eliteengineer7340
    @eliteengineer7340 17 днів тому +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 17 днів тому

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

    • @sleitnick1
      @sleitnick1  17 днів тому +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 17 днів тому

      @@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 17 днів тому +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 17 днів тому

    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 18 днів тому +1

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

    • @bacon_208
      @bacon_208 18 днів тому +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 17 днів тому +1

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

    • @Focusluvyou
      @Focusluvyou 17 днів тому

      ​@@littensy source?

    • @radwl
      @radwl 17 днів тому

      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 17 днів тому +1

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

  • @StarJ3M
    @StarJ3M 18 днів тому +1

    hi guys

  • @HashCollision
    @HashCollision 18 днів тому

    Thanks for explaining all this, Sleitnick.

  • @minerssp4363
    @minerssp4363 18 днів тому +3

    How is your life goin?

  • @ahmoin
    @ahmoin 17 днів тому

    task.wait(), what?

  • @miffclick3358
    @miffclick3358 18 днів тому +3

    Stop click baiting.

    • @dimitar.bogdanov
      @dimitar.bogdanov 18 днів тому +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  18 днів тому +16

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

    • @bacon_208
      @bacon_208 18 днів тому

      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 17 днів тому

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