Creating a function that parents player to object and then unparents it

I have a game where the player can rotate a level around them by pressing a button. but when I rotate the level a certain way the level heavily pushes the player; so much so that at times the player gets flung so fast it ignores any colliders I set up. I'm under the impression that parenting the object to the level while it's rotating and then un-parenting upon completion should solve this problem; but I haven't a clue how to go about doing that without using triggers. Could somebody help?

Added code I have so far


function RotateObjectForward(point : Vector3, axis : Vector3,rotateAmount : float, rotateTime : float) {
    var rotation = Quaternion.AngleAxis(rotateAmount, axis);
    var startPos : Vector3 = transform.position - point;
    var endPos : Vector3 = rotation * startPos; 
    var startRot : Quaternion = transform.rotation;
    var step : float = 0.0; //non-smoothed
    var smoothStep : float = 0.0; //smoothed
    var rate : float = 1.0/rotateTime; //amount to increase non-smooth step by
    Player.transform.parent = Parent.transform; 
    while(step < 1.0) { // until we're done
        step += Time.deltaTime * rate; //increase the step
        smoothStep = Mathf.SmoothStep(0.0, 1.0, step);
        transform.position = point + Vector3.Slerp(startPos, endPos, smoothStep);
        transform.rotation = startRot * Quaternion.Slerp(Quaternion.identity,
                                                         rotation, smoothStep);
        yield;
    }
    //finish any left-over
    if(step > 1.0) {
        transform.position = point + endPos;
        transform.rotation = startRot * rotation;
    }
    Player.transform.parent = null;

}


I get this weird error that says "Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption."

Set the transform of the instance of the prefab, instead of the actual prefab.