[Help] Scripting Overview, Controlling GameObjects Using Components question.

I am confused by a piece of example script in the documentation located here
https://docs.unity3d.com/Manual/ControllingGameObjectsComponents.html

At this piece of code.

And more specifically foreach (Transform t in transform), shouldn’t the code be
foreach (Transform t in waypoints) ?
I’m not seeing what array with the name “transform” it is referring to.

Transform implements IEnumerable. When you iterate over a transform, you get all the children of that transform (one level deep).

So that bit of code simply sets the waypoint array to be all the transform children of the transform the scipt is attached to. It’s a bit convoluted.