Gun beam doesnt come our of GunPoint

So I made a gun script where the beam comes out of the GunFirePoint Attachment in front of the gun. But if I try to click. The beam comes from the middle of the baseplate. Any help? Client Script:

local tool = script.Parent

local FirePoint = tool.Handle:FindFirstChild("GunFirePoint")

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()
local BulletFolder = game.Workspace.Bullets
local BulletFireEvent = game.ReplicatedStorage.GunRemotes.MegaGun.MegaGunFire

tool.Activated:Connect(function()
local MousePosition = mouse.Hit.p
local FirePosition = FirePoint.Position
BulletFireEvent:FireServer(MousePosition, FirePosition)
end)

This is the server script:

--Mega Gun
local MegaGunEvent = game.ReplicatedStorage.GunRemotes.MegaGun.MegaGunFire
local BulletFolder = game.Workspace.Bullets
local debris = game:GetService("Debris")

local range = 200

local function CreateBeam(FirePoint, direction)
	local midpoint = FirePoint + direction/2
	
	local part = Instance.new("Part")
	part.Parent = BulletFolder
	part.Anchored = true
	part.CanCollide = false
	
	part.Material = Enum.Material.Neon
	part.BrickColor = BrickColor.new("Really red")
	
	part.CFrame = CFrame.new(midpoint, FirePoint)
	part.Size = Vector3.new(.5, .5, direction.magnitude)
	
	debris:AddItem(part, 1)
end

MegaGunEvent.OnServerEvent:Connect(function(player, mousePos, firepointPos)
	local Direction = (mousePos - firepointPos).Unit * range
	local Result = workspace:Raycast(firepointPos, Direction)
	
	if Result then
		print(Result.Instance.Name)
	end
	CreateBeam(firepointPos, Direction)
end)

Your “midpoint” maths is off;
start by setting the part size before setting the cframe, then do this:
part.CFrame = CFrame.new(FirePoint, direction) * CFrame.new(0, 0, part.Size / -2)