Locking Y transition

Is there a way to lock the Y transition of the FPS controller when using this script?

function OnTriggerEnter () {
   var GO = GameObject.Find("Platform");//whatever the name of your moving platform is
   var GO1 = GameObject.Find("First Person Controller");

   GO1.transform.parent = GO.transform;     
}

function OnTriggerExit () {
   var GO = GameObject.Find("Platform");
   var GO1 = GameObject.Find("First Person Controller");

      GO1.transform.parent = null;
}

Thanks

If I understand what you’re asking, just use:

transform.position.y = 0; //change 0 to whatever value you desire

Well actually I want to turn of the gravity for the fps controller. So that it won’t fall when you are in the elevator when going down.

Turn it off in the inspector.

Choose the object the script is attached to, and under Rigid Body uncheck “Use Gravity”