Not able to teleport player

I’m attempting to teleport my player to a new position but for some reason the movement code is causing my character to instantly teleport back to it’s original position. I found that this piece of code seems to be causing the issue

moveDirection = new Vector3((Input.GetMouseButton(1) ? Input.GetAxis("Horizontal") : 0), 0, Input.GetAxis("Vertical"));

when that line is removed I can teleport without any issue when dragging the player into the portal manually. Not sure what I can do to fix the piece of code to allow the player to be teleported though. Here’s the code for the movement.

            if (grounded)
            {
				isJumping = false;
				
                moveDirection = new Vector3((Input.GetMouseButton(1) ? Input.GetAxis("Horizontal") : 0), 0, Input.GetAxis("Vertical"));

                if (Input.GetMouseButton(0) && Input.GetMouseButton(1))
                {
                        if (grounded)
                        {
                            if (!RightMouseDownOverGUI && !LeftMouseDownOverGUI)
                            {
                                moveDirection = new Vector3(0, 0, 1);
                            }

                        }
                }

                moveDirection = transform.TransformDirection(moveDirection);
                moveDirection *= runSpeed;

                if (Input.GetKeyDown(KeyCode.Space) && canJump)
                {
                    moveDirection.y = jumpSpeed;
                    isJumping = true;
                }
            }
			
			moveDirection.y -= gravity * Time.deltaTime;
			CollisionFlags flags;

			if (isJumping)
			{
				flags = controller.Move(moveDirection * Time.deltaTime);
			}
			else
			{
				flags = controller.Move((moveDirection + new Vector3(0, -100, 0)) * Time.deltaTime);   //-30 original
			}

			grounded = (flags & CollisionFlags.Below) != 0;

Before teleporting, disable the movement script (and if you have the character controller, disable it too). Then set your player position to a new vector3, then after teleporting, enable the movement script (and the charcontroller).