Question: I really need help, when I put Invoke in C#, I have this error: 

The local function 'RestartGame' is declared but never used Assembly-CSharp 

I really don't know why it is happening, but here is the code:

using UnityEngine;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour
{
 bool gameHasEnded = false;

```
public float restartDelay = 2f;
public void EndGame()
{
    if (gameHasEnded == false)
    {
        gameHasEnded = true;
        Debug.Log("GAME OVER");
        Invoke("RestartGame", restartDelay);
    }

    void RestartGame ()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }
}

```

}

Answer: 
unity manual: For better performance and maintability, use Coroutines instead.
<https://docs.unity3d.com/ScriptReference/MonoBehaviour.Invoke.html>

Try someting like this:

```
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour
{
    bool gameHasEnded = false;

    public float restartDelay = 2f;
    private IEnumerator coroutine;

    public void EndGame()
    {
        if (gameHasEnded == false)
        {
            gameHasEnded = true;
            Debug.Log("GAME OVER");

            coroutine = RestartDelayed(restartDelay);
            StartCoroutine(coroutine);
        }

        void RestartGame()
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }

        IEnumerator RestartDelayed(float delay)
        {
            yield return new WaitForSeconds(delay);
            RestartGame();
        }

    }
}

```

<https://docs.unity3d.com/ScriptReference/MonoBehaviour.StartCoroutine.html>
I upvoted flyingchris answer but just to explain your error message, I'm assuming its a yellow warning message, is that you are never calling the method RestartGame() directly anywhere in your code, you are invoking it however. Invoking is typically used for UnityEvents and coroutines are typically used for delaying a method.