I’m trying to go back to the main menu screen when the game ends and have the lobby shutdown and all the clients leave I tried to have it on the on destroy but that doesn’t work
this is what I have
public void GameFinish() {
Debug.Log("game end");
if (!IsServer)
{
GameFinishServerRpc();
return;
}
Disconnect();
}
[ServerRpc(RequireOwnership = false)]
void GameFinishServerRpc()
{
Disconnect();
}
public async void Disconnect()
{
using (new Load("Finishing the game...")) {
await MatchmakingService.LockLobby();
NetworkManager.Singleton.SceneManager.LoadScene("Lobby", LoadSceneMode.Single);
}
}
public override async void OnDestroy() {
base.OnDestroy();
await MatchmakingService.LeaveLobby();
if(NetworkManager.Singleton != null )NetworkManager.Singleton.Shutdown();
}