Remove GameObject From Array if it already exists?

This one has been stumping me for a while now. Essentially, I have a script setup that Creates a new GameObject Array for every letter typed into a string. The problem I having now is that every time I type something the GameObject gets added too and KEEPS the original GameObject. So for example… if I type “hi”. The “h” will be created twice and the “i” once.

I only want to create the “h” once… so my idea was to delete the object if it exists before instantiating it again. I should note that if I delete the string entirely, the object still remains, so I’m hoping his solves that issue as well. Here is what I have so far in the update() function.

  byte[] ASCIIBytes = Encoding.ASCII.GetBytes(test);

            float po = 0;
            foreach (byte b in ASCIIBytes)
            {

                Debug.Log(test);
               
                // check if certain "letter" already exists, if it does.. 
                // delete it before creating it again

                Instantiate(testObj**, new Vector3(po, 0, 0), Quaternion.Euler(270, -180, 0));**

po += kerning;

testObj**.transform.tag = “Word”;**

}
Any help or advice would greatly appreciated. Thank you!

Yes that would happen! You will need to delete all of the letters you created before. When you instantiate them add them to a List and the next time - delete all the existing ones before creating the new ones.