Car rotations not being set properly

When my player car hits a traffic trigger box, my script searches for an inactive car and sets it at the position of a spawner. Each traffic box has several spawners. Both the spawners and cars are stored in arrays.

For some reason, my code isn’t working. The cars don’t align properly with the spawners, both rotation and position. Some spawners are worse than others. It’s really strange… most of the time, the cars are put exactly where the spawners are but on a couple of them, the car is placed off to the side and it goes through the wall. Also, the rotation is never right.

What’s wrong with my code? I thought it looked pretty decent and should work but I’m having no luck…

function OnTriggerEnter(Other : Collider)
{
	if (Other.tag == "Player")
	{
		if (Traffic_Script.g_iCarsActive < Traffic_Script.g_iMaxActiveCars)
		{
			iRandom = Random.Range(0, SpawnerArray.Length + 1);
		
			for (var i = 0; i < iRandom; ++i)
			{
				iIndex = Random.Range(0, AICarArray.Length); 
				
				if (!AICarArray[iIndex].active)
				{
					AICarArray[iIndex].transform.position.x = SpawnerArray*.transform.position.x; // Set car pos to spawner pos*

_ AICarArray[iIndex].transform.position.y = SpawnerArray*.transform.position.y + 1;_
_ AICarArray[iIndex].transform.position.z = SpawnerArray.transform.position.z;
AICarArray[iIndex].transform.rotation = SpawnerArray.transform.rotation;
AICarArray[iIndex].SetActive(true);
}
else*

* {
print(“Car already active”);
}
}
}
}
}*_

Turns out it was an issue with another script. I had it adjusting the car’s Y axis rotation, depending on if the car was travelling north or south. When I put all the code into the script above, it worked. I have no idea whey it didn’t before, perhaps an order of operations thing…

Anyway, seems to work fine now!