Why do people do wait() after while true do instead of while wait() do?

I have been seeing a lot of people doing:

while true do
wait(1)
print("printing with cooldown")
end

But I always do:

while wait(1) do
print("printing with cooldown")
end

I don’t understand why people don’t replace true with wait(). I want to know if I’m doing a bad practice or not. Is there a good reason to do the first one instead of second one? Does it give better performance?

1 Like

For me i prefer useing while wait() do instead of while true do wait()

1 Like

It’s differents ways to script, the important is if works or not

1 Like

i dont think there is diffrence people just prefer the first one

1 Like

Thanks, I was confused if I was doing something stupid or not xD

1 Like

this only works because of what wait() returns

I’ve been told that this is less safe, but it’s actually perfectly safe(most of the time) because apparently wait() won’t change what it returns

I made a post about this exact thing

2 Likes

@rtvr56565 Reply’s is incorrect - Prefer the latter in a rare case where wait() doesn’t return anything, resulting in the while loop’s evaluation to result in not a truthy value, which will cause it not to run of course.

You expect your while loop’s evaluation to be always truthy if you want it to be. Hence why while wait() evaluation can possibly be unsafe.

1 Like

I don’t remember what topic I saw this in. But, a Developer Engagement member concluded that while wait() do
is safe.

Some says safe and some don’t? Welp.


this was said in my post by someone who knows what they are talking about, I think it’s safe enough to use

1 Like

That may be true, but this is also important:

1 Like

this is between while true do wait() and while wait() do

obviously wait() is bad practice but it’s good to know the difference between the two

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.