I got my script ready. But for some unknown reason unity crashes on activating the script.(No it does not give an error)
The code:
using UnityEngine;
using System.Collections;
public class score : MonoBehaviour {
public GUIText scoreText;
public float TimeScore;
public lives livesScript;
void Start () {
TimeScore = 0;
scoreText.text = "Time:0";
StartCoroutine(newScore());
}
IEnumerator newScore () {
while (true)
{
TimeScore = TimeScore + 1 * Time.deltaTime;
scoreText.text = "Time:" + TimeScore;
}
}
void Stop()
{
if (livesScript.Dead == true)
{
StopCoroutine(newScore());
}
}
}
I tested it and this script is what causes it. Any help?