I don't think "Total_LengthShape.distance.time" exists and also lines like... else if (Total_LengthShape.distance > 200) && (Total_LengthShape.distance.time -1 <= Total_LengthShape.distance.time)) cause syntax issues because of missing parentheses, it should be... else if ((Total_LengthShape.distance > 200) && (Total_LengthShape.distance.time -1 <= Total_LengthShape.distance.time)) I don't quite know what you're after but if the middle sphere should only be moving in the Y axis then why include the Z axis in the expression at all? I opened the scene and commented out the lines concerning the Z axis and the center sphere went up and down as the two end spheres moved back and forth.