Countdown after resume game.

Hey!
I’m currently working on a mobile game and I’m trying to make a countdown timer after you unpause the game.
I followed a tutorial to make it but it never worked for me.
Here is my code, I would love any help/suggestions:

//method number one for time(not working)
    IEnumerator cdToStart()
    {
        Debug.Log("TIME SHOULD START");
        while (cdTime > 0)
        {
            Debug.Log("TIME AT " + cdTime);
            cdDisplay.text = cdTime.ToString();
            yield return new WaitForSeconds(1f);
            cdTime--;
        }

        cdDisplay.text = "GO!";

        Time.timeScale = 1f;
        isPaused = false;
        
        yield return new WaitForSeconds(1f);

        CountDownUI.SetActive(false); 

    }

//method number two for time(not working)
    IEnumerator Countdown(int seconds)
    {
        int counter = seconds;
        while (counter > 0)
        {
            yield return new WaitForSeconds(1);
            counter--;
            cdDisplay.text = counter.ToString();
        }
        cdDisplay.text = "GO!";

        yield return new WaitForSeconds(1);

        Time.timeScale = 1f;
        isPaused = false;
        CountDownUI.SetActive(false);

    }

public void resumeGame()
    {
        pauseMenuUI.SetActive(false);
        CountDownUI.SetActive(true);
        Debug.Log("YOU PRESSED IT");
        //StartCoroutine(cdToStart());
        StartCoroutine(Countdown(5));
    }

On line 15 you’re setting Time.timeScale = 1f;. What was Time.timeScale before that? Just make sure Time.timeScale is not 0f when the non-working method is called. Instead maybe turn different scripts off to achieve the same thing

The time scale was 0f, maybe that why… But like I want to pause the game, when pressing resume do a 5 second countdown and then resume the game.

Since timescale=0 then you should use WaitForSecondsRealTime, which uses unscaled time.

For countdown checkout C# countdown timer - Questions & Answers - Unity Discussions
And I think you want to reset the countdown to whatever number and then reactivate it with a bool being true when resumed. but as they said with Time.timescale = 0; should stop everything from continuing and Time.timscale = 1; will resume everything again.