1st person Camera rotates suddenly in another direction when unparenting from a platform

I have a lift and when I collide with it a menu appears and you can choose a floor, then i make the 1st person controller a child and then I play the animation for the lift. on trigger exit I unpparent and let the 1st person controller to move freely. Everything works well when my lift is 0,0,0 in rotation.

But if I duplicate the lift and rotate it, then when I unparent, the first person controller jumps (rotates suddenly in another direction.) Is there any workaround for that? I cannot really understand what happens. Any help or suggestion would be great...

this is how I do the parenting through OnGUI

                FPCobject.transform.parent = currentPlatform.transform;
                moveFloor(liftMoveSound, 3, "platform2_3", currentPlatform);

here is how I do the unparenting

function OnTriggerExit (hit:Collider) 
{

if((hit.gameObject.tag == "liftani") && (showMenu== true))
    {
    FPCobject.transform.parent = null;
    MouseLook.mouseLock=false;
    showMenu = false;
    } 

There are two many unknowns here to be sure of what’s causing the problem. After the camera (or any object) is unparented from a rotating object, the camera should stop moving unless there is other code manipulating the camera.

The best way to determine the problem would be to create a simple test scenario where all the unknowns are removed. In this case, if you suspect the issue is with unparenting, create a new scene where all there is, is a rotating platform with a camera parented to it. Then, perhaps upon pressing space, the camera’s parent is set to null. If the behavior doesn’t occur in this situation (and it shouldn’t) then it’s likely something going on in your code.