Assign parent object to target

I have an object that flies around the screen, rotating randomly. I need another object that stays way above it, without rotating. The script on the child object just moves to target.position.x and y, and maintains the original rotation. It does exactly what I want, only I have to drag the parent into the inspector, and I have nearly a hundred of these objects in my scene, which would take for ever. You’re already thinking, “why doesn’t this idiot use a prefab?” Just believe me what I say that I’m in a unique situation and that isn’t an option, and it would take a long time to describe it.

That being said, I should be able to just assign the object’s parent to the target variable via script, right?

If you’re asking for a way to make one gameObject a child of another, use SetParent: Unity - Scripting API: Transform.SetParent

target = transform.parent;