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.
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.
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.