public IEnumerator GameOver() { if (currentscore > highscore) { highscore = currentscore; } PlayerPrefs.SetInt("Highscore", highscore); tileMoveSpeed = 0; player.GetComponentInChildren <Animator>().enabled = false; player.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; player.GetComponent <Rigidbody>().AddForce(Vector3.up * 10f, ForceMode.Impulse); player.GetComponent <Rigidbody>().AddForce(-Vector3.right * 5f, ForceMode.Impulse); player.GetComponent <Rigidbody>().AddTorque(Vector3.forward * 10f, ForceMode.Impulse); player.GetComponent <Rigidbody>().AddTorque(Vector3.right * 3f, ForceMode.Impulse); //Destroy(player.gameObject, 2); yield return(new WaitForSecondsRealtime(2)); gameOverScreen.SetActive(true); gameOverScreen.GetComponent <UnityEngine.UI.Text>().text = "Your Score: " + currentscore + "\n Highscore: " + highscore; }