Problem with making child an object

Hello!
I want an object to be a child of an other when 24 seconds pass.
Heres the script. It seems fine to me, but it doesn’t work. Any help?

#pragma strict

var secondpos : Transform;
function Start () {
yield WaitForSeconds(24);
Destroy(GetComponent(SmoothLookAt));
yield;
transform.rotation = Quaternion.identity;
transform.position = secondpos.transform.position;
gameObject.transform.parent = secondpos.transform;
}

function Update () {
}

Remove yield, and remove all the unneccesary transform calls

#pragma strict
 
var secondpos : Transform;
function Start () {
yield WaitForSeconds(24.0);
Destroy(GetComponent(SmoothLookAt));
transform.rotation = Quaternion.identity;

transform.parent = secondpos;
transform.localPosition = Vector3.zero;
}

But the object you have this script on is probably a character controller / rigidbody. (Am I right?). If so, linking wont do much. It only helps the rigid object inherit movement of parent if its sleeping I think.

New Answer based on new comments.

You say the camera moves with an animation to the empty game object and attach itself to this. Let’s see if we can work this out.

var secondPos:Transform;
function Start(){
   StartCoroutine(CamAnim());
}

function CamAnim(){
   animation.Play("CamAnimation");
   while(animation.IsPlaying("CamAnimation")){
     yield;
   }
   transform.parent = secondPos;
}

Since you have the animation done, it probably include already all movement and rotation so your camera should end up pretty much ready to go.

If not then you need to add some little details before and after the parenting, like you did in your example.