Script sets same value to other script in all objects instead of just one.

I’m adding a script component to an object in a loop like so:

 {
 clone = (GameObject)Instantiate(hexagon, new Vector3(x,y,z), transform.rotation);
 clone.transform.parent = gameObject.transform;
 clone.name = "gridTile:" + j + "," + i;
 clone.AddComponent<Properties>();
 }

Then later on in the code I’m looking for the object that was created (among many) and then setting a value in the Properties (again with a loop so that all objects have values in them) like so (edited to put more code that showed what I did wrong, should’ve made the new string array in the loop itself, thanks @Bonfire-Boy for the comments):

string[] conTemp = new string[6];
for loop{
clone = GameObject.Find("gridTile:" + j + "," + i);
{
string[] conTemp = {some numbers are set during code};
}
clone.GetComponent<Properties>().connections=conTemp;
}

Now the problem is, the code goes through them all and just sets them all the same value instead of different values. If I just run it out of the loop, it sets the right values but the loop somehow breaks it. For example the first one should have something like 1,2,3,4,5,6 as values but the second object should have 2,3,4,5,6,7 and instead they both get 2,3,4,5,6,7.

This is the only thing in the properties script:

public class Properties : MonoBehaviour {
public string[] connections = new string[6];
}

The whole code is uploaded as requested. As it is a messy work in progress code which is really long, I didn’t want to put it in the question itself and couldn’t figure out how to make a spoiler tag if it’s possible, so here it is as an attachment :
[79745-hexagonalhexgenerator.txt|79745]

Ok, I can see now that you’ve added the full code as an attachment. Sorry for not having spotted that when I posted my comment, above. Incidentally, this does demonstrate the importance of posting your actual code and not oversimplifying it for a question, because the issue in the full code is completely different (practically opposite to that in the simplified code).

The problem in the full code is that you are reusing the conTemp array and not creating it in the place shown in the simplified code!

You’re looping through your tiles, (re-)populating that array and then setting the tile’s connections variable to point to the one-and-only conTemp array. Like I say, this does not create a new array, it just makes that tile’s connections variable point to conTemp. So, naturally, they all end up pointing to the same thing.

Instead, you actually want to do what the code in the question does, and create a new array each time through the loop.

So I think all you need to do is move the declaration of conTemp from outside the loop to inside the loop, so that the real code looks more like the simplified code (but without those pointless curly brackets).