public void ButtonClicked(int LobbyID) { // passing the lobby id to the Join lobby script so that it can set the text in canvas joinLobby = GameObject.FindObjectOfType <JoinLobby>(); joinLobby.SetLobbyID(LobbyID); }