My coroutine is not getting called. ,

Hello I am new to unity, so I am sorry if the solution is incredibly simple but whenever I try to start a coroutine in unity is does not call on my IEnumerator fillTimer(), I am not quite sure what to do to so I am posting here. As for some background context I am trying to fill an image every 0.01 second, to give it a smooth increase, almost like an animation. Here is my code:`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class OfferCreationSystem : MonoBehaviour
{
public GameObject offer;
public Image successAnim;
public float animGain = 0.001f;

// Start is called before the first frame update
void Start()
{
    
}

public void OnButtonPress()
{
    StartCoroutine( fillTimer() );
    //hide();
    for (int i = 0; i < 10000; i++)
    {
        if(animGain != 100)
        {   
            IEnumerator fillTimer()
            {   
                yield return new WaitForSeconds(0.01f);
                successAnim.fillAmount = animGain;
                animGain += 0.001f;
            }
        }
    }
    
}

public void hide()
{
    offer.SetActive(false);
}

public void show()
{
    offer.SetActive(true);
}

}
`

,

I am not sure if this is the reason, but your fillTimer() method is not in the same scope as where you try to start it as a coroutine. It is inside an if block, which is itself inside a for loop. Why in the world would you want to write it that way? Move the method out to the same scope level as your other methods and it will probably work.