Tanks gun rotation problem on y axis

So basically i have a tank with a turret. The turret has a mask and a gun. We need to make it so that when the mask and gun move up or down (Orientation.X), their position (CFrame.Y) adds or subtracts 0.242. For example, if the mask and gun move up, their position (CFrame.Y) should add 0.242 from itself, Orientation.X - 1 times. If it moves down, their position (CFrame.Y) should subtract 0.242 to itself, Orientation.X * -1 - 1 times.
Here is the code i tried so far but it didnt worked

local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local mousePositionEvent = ReplicatedStorage:WaitForChild("MousePositionEvent")
local gunControlEvent = ReplicatedStorage:WaitForChild("GunControlEvent")

local turret = script.Parent
local turretMeshes = turret:WaitForChild("TurretMesh"):GetChildren()
local basePart = turret:WaitForChild("Meshpart3")
local gun = turret.TurretMesh:WaitForChild('gun50tp')
local speedValue = turret:WaitForChild("RotationSpeed")
local previousXOrientation = gun.Orientation.X

local targetCFrame = nil
local gunElevationSpeed = 0.5 
local maxElevationAngle = 5 
local minElevationAngle = -5 


gunControlEvent.OnServerEvent:Connect(function(player, deltaY)
	local gunOrientation = gun.Orientation
	local deltaOrientationX = deltaY * gunElevationSpeed
	local newOrientationX = math.clamp(gunOrientation.X + deltaOrientationX, minElevationAngle, maxElevationAngle)

	gun.Orientation = Vector3.new(newOrientationX, gunOrientation.Y, gunOrientation.Z)
	local xOrientation = gun.Orientation.X
	local yOffset = -0.242 * math.rad(xOrientation)
	gun.CFrame = gun.CFrame * CFrame.new(0, yOffset, 0)
	
end)