How to delay an action

Hi guys, i have this small function

 void SetCountText()
    {
        countText.text = "Count: " + count.ToString();
        if (count >= 1)
        {
            winText.text = "You Win!";
        }
    }

After the text “You win” I want to return to my main menu. I did it writing SceneManager.LoadScene(); and putting in the parenthesis the scene number of my menu, but i want that the redirect is delayed by a few second after the win text. How can i do this?

the simple way,

can also use coroutine and wait for seconds,

but make sure you don’t call it multiple times, if they get even more scores while waiting for it…
like adding bool isLoading = true, or something and checking it before calling again.

But in Invoke i had to call a method. The problem is that i need a delay using the SceneManager, not a method

yes, place the sceneload in separate method

He means something like this:

public class Something : MonoBehaviour
    {
        private string sceneName;

        public void ChangeSceneInvoker(string newSceneName)
        {
            sceneName = newSceneName;
            Invoke("ChangeScene", 2f);
        }

        private void ChangeScene()
        {
            SceneManager.LoadScene(sceneName);
        }
    }

Thank you guys. Another little question. If i wanted to open a menu by clicking a button, what i have to do? I looked for solutions , but i only found a way with animation. Is there a simple way?

P.S. and if i want to load the scene with a little effect? Maybe with a fade. Is it possible?

Create a method that toggles the active state. Connect that to an OnClick event for the button.