Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How does "wait()" function work exactly?

Asked by 6 years ago

According to the wiki, the wait() function, when the seconds parameter is left without specifying, it will yield for a small amount of time. How much time does that small amount of time exactly returns? The wiki says "usually close to 1/30th of a second". The use of the word usually leads me to believe its not a constant value. How, then, does that value gets calculated?

Any help will be greatly appreciated.

0
tiraner300 stop moderating with "not constructive" so much. It is for script requests and posts that are descriptive but borderline off-topic. cabbler 1942 — 6y

4 answers

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
6 years ago

The only reason it says usually is because when the game has some form of lag, it could take longer.

For instance, in a game with a lot of lag, a wait(1) could take 3 seconds instead, which is why wait() also returns the actual time it waited.

Eg.


while true do local WaitTime = Wait(1) print(WaitTime) end
0
Thanks! Le_Teapots 913 — 6y
Ad
Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
6 years ago

That's only one of several ways of interacting with the task scheduler. Based on this I assume delayed tasks are tied to the framerate - wait being resumed every other frame. There is a lot to be said about schedulers and frames but all you need to know is: since the 60fps framerate itself is approximated (that's just how computers work), wait is guaranteed to be approximated.

Log in to vote
0
Answered by 6 years ago

the wait() function waits the amount of time that is inside the parentheses, for example wait(1) will wait 1 second and wait(100) will wait 100 seconds.

wait() is the shortest possible wait time which is around 33.3333333 milliseconds or 0.0333333333 seconds

Log in to vote
-1
Answered by
Elixcore 1337 Moderation Voter
6 years ago
Edited 6 years ago

the wait() function waits the amount of time that is inside the parentheses, for example wait(1) will wait 1 second and wait(100) will wait 100 seconds.

wait() is the shortest possible wait time which is around 33.3333333 milliseconds or 0.0333333333 seconds. hope i helped.

Answer this question