Does task.wait() stop player.added() etc from firing?

I am making a round based system, and I want to be able to get when a player leaves and joins in order to run functions, but I want be able to keep track of time. Is there some other way to do it, or can I just do my playeradded:connect function above all my serial task.wait game loops, and it will work? I’m confused, and testing it i’ve had a lot of problems.

Depends on when your wait gets read. If it’s not fired immediately when a script starts it won’t yield, and it will read all the connections that are outside of a block. But if you have a lonely while loop that gets fired instantly it shouldn’t work. Best thing to do is make sure it doesn’t yield (spawn, coroutine) or change the order of your script. To add to your question, if the connection is above the while loop it should work.


Connections are based on threads - as long as your Players.PlayerAdded:Connect(function) line is actually executed (its put above the loop, or you nest the loop in a coroutine) you will be fine.


Both responses were solutions, I picked the first one. Thanks to both of you though.


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