Here’s a video to help explain the problem. When everyone in a lobby is ready it puts them in the game, but then some other code plays when another person tries to lobby.
Looking at your code I saw that the server broadcasts events like lobbyCreated and lobbyFound to all conected socket… and I think this is the cause?
For example, if one client triggers the createLobby event, the server will create a lobby and then emits the event to all clients, so, if a client trigger the findLobby event and finds a lobby, the server will emit the loobyFound event to all clients.
I think that if you want the code to run only for the client that triggered the event, you should use socket.emit() instead of io.sockets.emit().
Idk how to apply that to your code right now (kinda busy) but this should clarify your problem a little