If you want an unconditional infinite loop, while true do .. end
is actually the way to go.
Inside, you can use the wait
method of Events to avoid having to utilize busy waits, for increased efficiency:
2 | script.Parent.Touched:wait() |
3 | print ( "script.Parent was Touched!" ) |
If you ever run into a case of having to use some kind of busy wait:
1 | while not script:FindFirstChild( "LocalManager" ) do |
Try and script to avoid that:
1 | while not script:FindFirstChild( "LocalManager" ) do |
2 | script.ChildAdded:wait() |
And if you can't figure out how to do that, by all means ask here.
(In this case, you could just use WaitForChild
, but this is the best example of this I could think of right now. I'd actually be surprised if this wasn't the code for WaitForChild internally.)
Locked by adark and evaera
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?