What I’m basically asking for is the default wait time if you don’t put anything inside the brackets.
Sorry if this sounds like a noobish question.
What I’m basically asking for is the default wait time if you don’t put anything inside the brackets.
Sorry if this sounds like a noobish question.
I’ve seen it answered before and its something like 0.05 if I remember correctly.
Wait is done in seconds, so that if you was to run a loop with nothing in the wait it would run about 200 times a second which for some scripts is enough to crash games.
A bit of advice, even if you want to run it 200 times a second, still put a number in there so you can be certain its doing what you want it to.
No, wait()
yields the thread for 1/30th of a second or 0.03333
seconds.
wait() is not an exact science, neither is it with a number inside. You can get an average of wait() with this:
waited = wait()
for i=2, 50 do -- skip one cycle because we wait above
local new = wait()
waited += new
waited /= 2
print("Waited " .. new)
end
print("Waited an average of: " .. waited)
I got the following output:
Waited 1.8574200374155
Waited 2.2609276655935
Waited 0.31333922615204
Waited 0.047317504352577
Waited 0.032834539640589
Waited 0.033768102464819
Waited 0.032842812972831
Waited 0.033548362757301
Waited 0.032377851693582
Waited 0.033574175553895
Waited 0.032724669786148
Waited 0.032923560696418
Waited 0.033695959006764
Waited 0.032801446310714
Waited 0.033847195522412
Waited 0.032665432726844
Waited 0.032834870573879
Waited 0.033885914717757
Waited 0.032825273508024
Waited 0.032850424438493
Waited 0.032967243891562
Waited 0.033524204626701
Waited 0.033046006015866
Waited 0.033676433942219
Waited 0.032918596697073
Waited 0.032886165234231
Waited 0.033813440325957
Waited 0.032632008463679
Waited 0.032863330837245
Waited 0.033807152593909
Waited 0.032766036448265
Waited 0.032854726571259
Waited 0.032817992975652
Waited 0.033841569656488
Waited 0.03278523057952
Waited 0.033087372677528
Waited 0.033489787564122
Waited 0.040874894969875
Waited 0.041746573268483
Waited 0.032855388437838
Waited 0.033768764331398
Waited 0.032782914046038
Waited 0.033000006287693
Waited 0.033615211282722
Waited 0.032835863373293
Waited 0.032826928174472
Waited 0.033789282195812
Waited 0.032784568712941
Waited 0.032772655114059
Waited an average of: 0.032931571860888
It’s never exact. Regardless, you probably shouldn’t be using wait() anyway: Avoiding wait() and why
(this specifically:)
I don’t recommend using wait() without argument though, it can be a bit unreliable. If you want to wait exactly one frame, use RunService’s events.
Ah I see now. I will avoid using wait in the future then.