Hunger Bar not working :c

Hi, I have been working on Hunger Bar for My game from Unity learn pathway “junior Programmer”.
I cannot find why is my hunger bar not working, after 4 hours i copied whole code from step-by-step solution and it isn’t still working. Unity doesn’t give me any error, i have watched like 2 videos about creating some kind of bars and i still don’t have a single idea where is problem. Here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class HungerBar : MonoBehaviour
{
    public Slider slider;
    public int amountToBeFed = 2;
    public int currentFedAmount = 0;


    void Start()
    {
        slider.maxValue = amountToBeFed;
        slider.value = 0;
        slider.fillRect.gameObject.SetActive(false);
    }
    public void SetHunger(int Hunger)
    {
        currentFedAmount += Hunger;
        slider.fillRect.gameObject.SetActive(true);
        slider.value = currentFedAmount;
        if (currentFedAmount >= amountToBeFed)
        {
            Destroy(gameObject, 0.1f);
        }
    }
}

And here is another one:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DetectCollisions : MonoBehaviour
{
    // Update is called once per frame
    void Start()
    {
   
    }
    // when two gameobjects collide with themselfs, they get destroyed
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            GameManager.lives -= GameManager.livesDecrease;
            GameManager.GameOvercondition();
            Debug.Log($"Lives: { GameManager.lives }");
            Destroy(gameObject);
        }
        if (other.CompareTag("Animal"))
        {
            other.GetComponent<HungerBar>().SetHunger(1);
            Destroy(other.gameObject);
            GameManager.score += 5;
            Debug.Log(GameManager.score);
        }
    }

}

Thank you all for your time and help.

Hello,

Not sure if you’re still having an issue but.

I had a similar issue and had to play with the SliderCanvas Rect Transform in the UI on each animal it didn’t seem to be the same as the settings the tutorial suggested. Each time I put the slidercanvas into the prefab it was tiny so had to mess wit the transform of each:
8951157--1228875--upload_2023-4-15_15-17-29.png
8951157--1228878--upload_2023-4-15_15-18-8.png
8951157--1228881--upload_2023-4-15_15-19-27.png
Might be worth playing with these to see if the hungar bars appear for you.