There is a point at which it will timeout. The wait only delays it a bit. Also, just because something works doesn’t mean you should be doing it that way. Loops should be used very sparingly, ideally never. This is why we use events instead. In this case, all you need is two points. The point at which the player joins and the point at which a badge is awarded to a player. That means that the execution only happens a minimum of once and a maximum of twice. Where as looping will spam constantly in the background.
When getting into programming, it’s important to realize the difference between just getting something to work and getting something to work efficiently. Computers don’t have unlimited resources. Sure, one loop like this might not cause any issues, but it’s still very bad practice. Also, your test was only with one player. But if there are multiple players, it problem grows exponentially.
In short, please avoid using loops wherever possible. There is almost always a better method.