public void Damage(float hitAmount) { health -= hitAmount; if (health <= 0) { Instantiate(deathParticles, transform.position, Quaternion.identity); Debug.Log($"{transform.name} is Dead"); DeathEvent.Invoke(); DeathEvent.RemoveAllListeners(); purse.increaseCoinCount(); Destroy(this.gameObject); } float percentage = healthPerUnit * health; Vector3 newHealthAmount = new Vector3(percentage / 100f, healthBar.localScale.y, healthBar.localScale.z); healthBar.localScale = newHealthAmount; }