Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How does "wait()" function work exactly?

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.

1 comment

0

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

4 answers

✓ Accepted answer

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

1 comment

0

Thanks!

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.

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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.