I have a script for the player so when the player object is destroyed, a gui text appears but it wont work. When the player dies nothing happens.
CODE
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Player : MonoBehaviour
{
public Text countText;
private int count;
public Text endText;
void Start ()
{
count = 0;
SetCountText ();
endText.text = "";
}
void OnTriggerEnter2D(Collider2D col)
{
if(col.gameObject.tag == "Coin")
{
col.gameObject.SetActive (false);
count = count + 1;
SetCountText ();
} else if (col.gameObject.tag == "Enemy")
{
Destroy(gameObject);
}
}
void SetCountText ()
{
countText.text = " " + count.ToString ();
if (gameObject == null) {
endText.text = " " + count.ToString ();
}
}
}