adding a health bar to the boss

So I made a code when I hit the boss 10 times it dies but I want to add a health bar to the code so when I hit the boss the health goes down. I made a simple slider for the health I just want to know how to add the health bar feature.

using System.Collections.Generic;
using UnityEngine;

public class BossHealth : MonoBehaviour
{

   [SerializeField] float health, maxHealth = 10f;

   private void Start()
   {
        health = maxHealth;
   }

   public void TakeDamage(float damageAmount)
   {
          health -= damageAmount;

          if(health <= 0)
          {
                Destroy(gameObject);
          }
   }

}

  • Set the canvas’ “Word Space” to true. Set slider’s min and max value.

  • Put it above boss’ head.

  • Update canvas’ position every frame.

  • Set slider’s value in TakeDamage()

  • If the boss is destroyed, destroy the canvas also.