GameObject needs to rotate and and move based off another game objects rotation

I have an object in this case a weapon for the player character. The player can aim the weapon which will instantiate a prefab of the player holding the weapon up in eye sight. This is an fps so the camera acts as the head of the player. When the player turns left and right, the whole body moves and the camera is a child of the body so it turns with that. However, when the player looks up and down on the y axis, only the camera will rotate. What I’m struggling with is when the camera rotates up and down I need the weapon to follow the line of sight of the camera, just like an fps game. I assume the weapon will need to rotate the same as the camera does, which I’ve done but I need it to move up and down based off the rotation and I’m at a loss. Bare with the code, I’m new to unity and just testing out some things. Here’s the gun script.

void Start()
{
    pControlHolder = GameObject.FindGameObjectWithTag("PControlHolder").GetComponent<PControlHolder>();
    logicManager = GameObject.FindGameObjectWithTag("LogicManager").GetComponent<LogicManager>();
}

void Update()
{
    // This code rotates the the gun the exact same as the camera
    float verticalInput = -pControlHolder.RotateInput.y;
    Vector3 gunRotation = new Vector3(logicManager.verticalRotation, 0f, 0f);
    gunTransform.localEulerAngles = gunRotation;
}

}

Some of the variables come from other scripts.
The pControlHolder.RotateInput.y = the rotation value of the camera
VerticalRotation is the RotateInput.y * 2 (Rotation Speed)

I need the GunGameObject position to move up and down as well as rotate with the camera.

Can you just make the gun a child of the camera? Then no code needed