public void TakeDamage(int damage) { Instantiate(bloodParticle, transform.position, Quaternion.identity); health -= damage; AudioScript audio = GameObject.FindGameObjectWithTag("Audio").GetComponent <AudioScript>(); //Check to see if the person who got hurt was enemy or player, and play the right audio. if (gameObject.transform.CompareTag("Player")) { audio.TDamageSound(); } else { audio.DDamageSound(); } }