using game.connected_players the index returned from a for loop is NOT the player index http://lua-api.factorio.com/latest/LuaG ... ed_players
Without this change the gui will close immediately for some players when opening after players in mp disconnect/leave
Fixed code below by replacing index with player.index
on_tick