Photon, how to search for a room accepted by the user and join it ?

I have a multiplayer game where a user can create a room with a name , and his friends can join it by searching it .I know how to accept the text and I’m using this script to search the room and join it

RoomInfo[] rooms;
    public void SearchAndJoin(){
        if(PhotonNetwork.connectionStateDetailed == ClientState.JoinedLobby){
            if(inputFieldForRoomName.text == ""){           
                for ( int i = 1;i < rooms.Length; i++){
                     if (rooms[i].Name != inputFieldForRoomName.text)
                        NoRoom = true;
                    else NoRoom = false;
                }
                if (NoRoom == false){
                    PhotonNetwork.JoinRoom(inputFieldForRoomName.text);
                }
                else errorText.text = "NO SUCH ROOM, try again";
            }
        }
    }

But when I assign this to a button and press it, nothing happens, not even the error text box shows anything ! Any help is appreciated.Thanks.

Did you debug your button and script? Does it call JoinRoom()?
You don’t set rooms to a value, so maybe it’s not doing what you plan?

If a player enters the name of a room, you don’t have to check if the room is in some list. You just JoinRoom(name) and if that fails, you know the room is full, no longer existing or there’s a typo.