Progress Bar

I have a game in which I need a progress bar to display the current amount of objects that are placed in the correct slots. I have this script but it loads it as full amount of 5. Please help if possible. Thanks

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

public class RPB : MonoBehaviour {

	public Transform LoadingBar;
	public Transform TextIndicator;
	public Transform TextLoading;
	[SerializeField] private float currentAmount;
	[SerializeField] private int count = 0;

	void Start(){
		currentAmount = count;
		CountThis();
	}

	void Update(){

	}

	void CountThis() {
		for (int i = 0; i < 6; i = i+1) {
				Debug.Log (currentAmount);
				count = i;
				currentAmount = count;

		}if (currentAmount < 6) {
			TextIndicator.GetComponent<Text> ().text = ((int)currentAmount).ToString () + "/5";
			TextLoading.gameObject.SetActive (true);
		}else {
			TextLoading.gameObject.SetActive(false);
			TextIndicator.GetComponent<Text>().text = "DONE!";
			Debug.Log(currentAmount);
		}
		LoadingBar.GetComponent<Image> ().fillAmount = currentAmount / 5 ;
	}


}

You need to convert your CountThis method into a coroutine and slowly iterate to make the bar appear as if it’s moving. Replace your CountThis method with something like:

 IEnumerator CountThis() {
Text output = TextIndicator.GetComponent<Text>();
         for (int i = 0; i < 6; i++) {
                 count = i;
                 currentAmount = count;
                yield return new WaitForSeconds(1);
if (currentAmount < 6) {
            output.text = ((int)currentAmount).ToString () + "/5";
             TextLoading.gameObject.SetActive (true);
         }else {
           TextLoading.gameObject.SetActive(false);
           output.text = "DONE!";
           yield break;
         }
   }
         LoadingBar.GetComponent<Image> ().fillAmount = currentAmount / 5 ;
}


Also be sure to initialize it in the Start method properly, like this:

StartCoroutine(CountThis());