Child of a Clone game object

Hi there guys
I have two dice which each i have attach 6 empty game object inside. When these line runs:
dice1.Find(i.ToString()).transform.position.y;

dice2.Find(i.ToString()).transform.position.y;

dice2.Find is searching for dice1.Find child object… why is that happening?

var dice1 : GameObject;
var dice2 : GameObject;

function GetRollNumber() {
	var point1 : short = 0;
	var point2 : short = 0;
	var ySide1 : float = 0;
	var ySide2 : float = 0;
	for (var i = 1; i <= 6; i++) {
		var yPos1 = dice1.Find(i.ToString()).transform.position.y;
		var yPos2 = dice2.Find(i.ToString()).transform.position.y;
		if (yPos1 > ySide1) {
			ySide1 = yPos1;
			point1 = i;
		}
		if (yPos2 > ySide2) {
			ySide2 = yPos2;
			point2 = i;
		}
	}
	return point1 + point2; //WTF
}

GameObject.Find is a static method, thus not linked to a GameObject.
When you’re calling dice1/2.Find, it searches in the whole scene for the first instance of a GameObject with the specified name. If your die faces are called exactly the same, it gonna returns the first one in alphabetical order, there returning the side from dice1.

Try using a loop with GetChild(int) on your dice instead.

I fix it now mate, i just replace .find with this:

		var yPos1 = dice1.transform.GetChild(i).transform.position.y;
		var yPos2 = dice2.transform.GetChild(i).transform.position.y