C# Help (It Stopped working and i don't know why) [Solved]

I’m having trouble with the IEnumerator SpawnWaves () and updating the GUIText, i didn’t touch the code for either, so i’m very very lost (if you cant tell i’m new here)

using UnityEngine;
using System.Collections;

public class GameControler : 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;

private bool gameOver;
private 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)
{
yield return new WaitForSeconds (startWait);
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);

if (gameOver)
{
restartText.text = “Press ‘R’ for 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;

}
}

First of all, [ code] code tags[/code].

Are you getting any error message in your console? Have you tried putting in Debug.Log’s in various places to see if the code is actually being run?

As already mentioned, use code tags!
I just had a quick glance and saw that you used start () instead of Start (). It has to be upper case.

1 Like

that was it, always the little things eh?