Make shift "gun" points down when falling or jumping

So my make shift “gun” keeps looking down when you fall, it’s really weird. The gun has 4 parts: the invisible bullet spawnpoint (sphere),the tip of the gun (sphere), the body of the gun (cylinder), and all those parts are children to an empty GameObject which is positioned in the center of the cube, and is a child of the player (basic unity cube). That way it all rotates around my player’s body. My problem can be seen here: - YouTube if you need visual help understanding what I mean. When I jump, the gun moves up and down, which I’m fine with, but when I fall off the edge, the gun looks straight down. I have the gun looking at the mouse cursor at all times (this is attached to every part of the gun, including the empty GameObject):

function Update () {
transform.LookAt(PlayerScript.hitPoint); //get mouse position (hitPoint) from my PlayerScript
transform.Rotate(0,-90,0);     }

To find the mouse position, I use the following code attached to my playerscript:

// this creates a horizontal plane passing through this object's center
var plane = Plane(transform.position, Vector3.up);
// create a ray from the mousePosition
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
// plane.Raycast returns the distance from the ray start to the hit point
var distance: float;
if (plane.Raycast(ray, distance)){
    // some point of the plane was hit - get its coordinates
    hitPoint = ray.GetPoint(distance);
    hitPoint.z = -19; // always -19 because of no movement on z axis
 }

So any help would be greatly appreciated. Once again, I’m trying to solve the problem with the “gun” not looking at the mouse when falling, I want it to always look at the mouse. Also as a bonus question, if someone can solve the problem of my charcter not smoothly falling (see 10-14 seconds on the video) that would be great, but I don’t expect that to be solved cause it’s not the main problem in the question. Just incase you know the answer or think you do, here’s my code for jumping:

if (controller.isGrounded) {
    
    jump = false;
    vertVel = 0;
            
    if (Input.GetButton ("Jump") && jump == false) {
        moveDirection.y = jumpSpeed;
        vertVel = jumpSpeed;
        jump = true;
    }
}

// Apply gravity
vertVel -= gravity * Time.deltaTime; // apply gravity to the vertical velocity
moveDirection.y = vertVel;

thank you for any help which may come from this, you guys are an amazing community!

*All code provide is in the Update function

I don’t know if this is the main cause, but the plane generation is wrong:

// this creates a horizontal plane passing through this object's center
var plane = Plane(transform.position, Vector3.up);

The arguments for Plane are reversed - they should be:

// this creates a horizontal plane passing through this object's center
var plane = Plane(Vector3.up, transform.position);

In the original code, the plane would rotate as the player moves, producing weird results depending on the player position relative to 0,0,0 (I hate to say this, but this wrong code seems to have been extracted from an older answer of mine…)