space shooter restart not worknig

hey im doing the space shooter tutorial and cant seem to get my game to restart when i press the R key.

using UnityEngine;
using System.Collections;

public class Gamecontroller : MonoBehaviour
{

public GameObject hazard;
public Vector3 SpawnValues;
public int hazardcount;
public float SpawnWait;
public float StartWait;
public float WaveWait;

public GUIText scoreText;
public GUIText restartText;
public GUIText gameOverText;

public bool gameOver;
public bool restart;
private int score;

void Start ()
{
    gameOver = false;
    restart = false;
    restartText.text = "";
    gameOverText.text = "";
    score = 0;
    Updatescore();
   StartCoroutine (SpawnWaves ());
}

void update()
{
    if (restart)
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            Application.LoadLevel(Application.loadedLevel);

        }
    }
}

IEnumerator SpawnWaves ()
{
    while (true)
    {
        for (int i = 0; i < hazardcount; i++)
        {
            yield return new WaitForSeconds(StartWait);
            Vector3 SpawnPosition = new Vector3(Random.Range(-SpawnValues.x, SpawnValues.x), SpawnValues.y, SpawnValues.z);
            Quaternion SpawnRotation = Quaternion.identity;
            Instantiate(hazard, SpawnPosition, SpawnRotation);
            yield return new WaitForSeconds(SpawnWait);
        }
        yield return new WaitForSeconds(WaveWait);
        if (gameOver)
        {
            restartText.text = "Press 'R' to Restart";
            restart = true;
            break;
        }
    }
}

public void AddScore(int newScoreValue)
{
    score += newScoreValue;
    Updatescore();
}

void Updatescore()
{
    scoreText.text = "score: " + score;
}
public void GameOver ()
{
    gameOverText.text = "Game Over";
    gameOver = true;
}

}

Methods are case sensitive, your “update” method needs to have a capital U, rename it to “Update” instead of “update”. Unity calls them explicitly

Thanks for the help i didnt notice that when i check through my code

One thing I changed from the tutorial was instead of waiting for the entire wave to be over to restart, I made it so the player can restart once the game is over. Here’s what I did:

.

I deleted the restart variable.

.

My Update function checks for gameOver instead of restart:

.

private void Update() {

.

if(gameOver && Input.GetKeyDown(KeyCode.R) ) {

.

    Application.LoadLevel(Application.loadedLevel);

.

}

.

}

.

My SpawnWaves function loops while gameOver is false instead of while true and breaking:

.

IEnumerator SpawnWaves() { //return type for waitforseconds

.

    yield return new WaitForSeconds(startWait);

.

    while(!gameOver) {

.

        for (int i = 0; i < hazardCount; i++) {

.

            Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);

.

           Quaternion spawnRotation = Quaternion.identity;

.

            Instantiate(hazard, spawnPosition, spawnRotation);

.

            yield return new WaitForSeconds(spawnWait);

.

        }

.

       yield return new WaitForSeconds(waveWait);            

.

    }

.

}

.

Lastly, my GameOver function also displays the restart text:

.

public void GameOver() {

.

    gameOver = true;

.

    gameOverText.text = "Game Over";

.

    restartText.text = "Press 'R' to restart";

.

}