Wait(negative number) waits around the same time as wait() - why?

Hi!
This is my first topic, so please tell me if I did something wrong and if the category is wrong! Also, if there is a topic similar to this, please link it to me! I couldn’t find anything. And sorry if the question sounds dumb!

Why does wait(negative number) wait the same amount of time as wait()?

Me and some other people tried testing this out. We thought it would just error or wait forever (a bit like TweenService's repeat thing). So I tried this code out:
local tickBeforeWait = tick()
wait(-1) -- I also tried different numbers like -50, -10, -13, etc..
local tickAfterWait = tick()

print(tickAfterWait - tickBeforeWait)

But it didn’t print what we expected it to print. Instead, it printed this…

-- [[ Output ]] -- 
0.033968687057495

…which is about the same as wait().

But why?

We were very curious onto why this happens. So we thought the best place to ask would be here! Again, sorry if it's kind of a "dumb" question or something, but I hope that someone can explain to me why this happens. That would be very appreciated.

Thank you! :slight_smile:

I mean, what do you expect? to finish waiting before it starts?

Roblox simply clamps the input to the function to a min value of 0 before executing (it’s actual min value is something like 29ms but it’s dependent on the environment)

The alternative would be going back in time and that unfortunately isn’t an option.

4 Likes

Nope, like I said, I expected it to wait infinitely or just error.

Else you can use the tick function:

local Time = tick()

wait(5)
print(tick() - Time)
1 Like

Oh, alright. Thank you for taking your time! :smiley:

The funny thing is also how wait(math.huge) is the same as just wait(). Feel free to test it out if you don’t believe me.

1 Like

Explain to me how a negative wait time would be possible?

The question wasn’t a “why don’t I go back in time,” it was more of a “why does it wait as much as the minimum wait value.” Obviously, for now at least, time travelling isn’t possible. I just was wondering why it didn’t do what I expected it to do - so why it didn’t error (which Fm_Trick answered, thank you!). Sorry if you understood it wrong.

To call wait() for any value < ~ 1/30 seconds, run this in the command bar

settings().Lua.DefaultWaitTime = 0

This isn’t advised but it’ll decrease how long calling wait() yields for.
0.02999999999999999889 to 0.0019934177398682

2 Likes