Loop not working as expected

Sorry the question doesn’t provide more detail its a little hard to explain

Basically I have a loop being called under a specific circumstance in void Update however when I add an integer in a seperate coroutine (that I call with the loop) it seems to constantly add numbers, it adds about 7 to 14 onto the variable and stops and does it again next time its called

public class InventoryExp : MonoBehaviour
{

    public Block.BlockType hitBlockType;
    private Block.BlockType lastBlockHit;
    public Block.BlockType[] BlockArray;
    private int blockHealth;
    public GameObject[] Slot;
    public Sprite Alpha;
    public Image[] SlotImage;
    public Sprite[] BlockSprites;
    public int[] BlockAmount;
    public bool[] BlockInInventory;
    private int ID;
    private int SlotID;
    private Text BlockAmountText;

    // Use this for initialization
    void Start ()
    {
        hitBlockType = Block.BlockType.AIR;
        ID = 0;
        blockHealth = 2;
    }

    IEnumerator MakeSlot()
    {
        yield return new WaitForSeconds(0.1f);
        SlotImage[SlotID].sprite = BlockSprites[ID];
        BlockAmount[ID] = 1;
        BlockAmountText = Slot[ID].GetComponentInChildren<Text>();
        BlockAmountText.text = BlockAmount[ID].ToString();
        BlockInInventory[ID] = true;
        yield return new WaitForSeconds(0.1f);
    }

    IEnumerator AddToSlot()
    {
        yield return new WaitForSeconds(0.1f);
        BlockAmount[ID] += 1;
        BlockAmountText = Slot[ID].GetComponentInChildren<Text>();
        BlockAmountText.text = BlockAmount[ID].ToString();
        yield return new WaitForSeconds(0.1f);
    }

    public IEnumerator GetBlock()
    {
        blockHealth = GameObject.Find("Camera").GetComponent<BlockInteraction>().Health;
        yield return new WaitForSeconds(0.1f);
        hitBlockType = GameObject.Find("Camera").GetComponent<BlockInteraction>().typeOfBlock;
    }

    // Update is called once per frame
    void Update () {

        if (hitBlockType != Block.BlockType.AIR)
        {
            ID = 0;
            if (blockHealth == 0)
            {
                while (ID != BlockArray.Length - 1)
                {
                    if (hitBlockType == BlockArray[ID])
                    {
                        SlotImage[SlotID] = Slot[SlotID].gameObject.GetComponent<Image>();

                        if (BlockInInventory[ID] == true)
                        {
                            StartCoroutine(AddToSlot());
                            return;
                        }

                        else if (SlotImage[SlotID].sprite == Alpha)
                        {
                            StartCoroutine(MakeSlot());
                            return;
                        }

                        else if (SlotImage[SlotID].sprite != Alpha)
                        {
                            SlotID = SlotID + 1;
                        }
                    }

                    else if (hitBlockType != BlockArray[ID])
                    {
                        ID = ID + 1;
                    }

                }
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            StartCoroutine(GetBlock());
        }

    }
}

Would appreciate it if anybody could work this out I’ve been scratching my head for hours

Take back what I said I fixed it! This is what I did after some googling once you guys said the Coroutine was running multiple times, `

IEnumerator AddToSlot()
{
coroutineStarted = true;
yield return new WaitForSeconds(0.1f);
BlockAmount[ID] += 1;
BlockAmountText = Slot[ID].GetComponentInChildren();
BlockAmountText.text = BlockAmount[ID].ToString();
coroutineStarted = false;
StopCoroutine(AddToSlot());
yield return new WaitForSeconds(0.1f);
}

                    if (BlockInInventory[ID] == true)
                    {
                        if (coroutineStarted == false)
                        {
                            StartCoroutine(AddToSlot());
                        }
                        return;
                    }

`

Thanks So much guys :smiley: