Problem with Instantiate and IF

Hi, I need your help because I can’t really see what’s wrong here.
I want my script to check if “AttEnergy” is more than a particular number (let’s say 101) and if it’s that the case :

  1. make a simple AttEnergy -= 100 (subtract 100 from the initial value)
  2. Instantiate and make a copy of himself

My problem is that with my code the object copy himself but “forget” to subtract 100, the strange thing is that if I delete the instantiate line it does subtract 100.
Can you help me understanding what’s wrong and how to make it do both the operation ?

    using UnityEngine;
    using System.Collections;
    public class CellController : MonoBehaviour
             public int AttEnergy;
             private int MaxEnergy = 200;
             private float RegEnergy = 1;
             private float EnergyAdder;
             public GameObject ThingToBeCloned;

void Update()
            if (AttEnergy < MaxEnergy)
        EnergyAdder += RegEnergy * Time.deltaTime;
        AttEnergy = (int)EnergyAdder;

            if (AttEnergy >= 100)
                AttEnergy -= 100;
    void CloneFunction()

You’re cloning ‘ThingToBeClones’ instead of the current GameObject, and you said it clones itself, so I guess there’s one error. Also, you substract 100 from AttEnergy but not from EnergyAdder, so it’ll grow forever, and at some point removing 100 won’t be enough to set it below MaxEnergy. And you check against MaxEnergy first, and then against a hardcoded 100… That looks odd.