Attachment for beam spawns with a huge offset

So, I’m working on creating a gun system for a game. It uses beams for the bullet effect, but the attachment for the beam spawns at a huge offset:

Video Demonstrating:

And here is my coding: (EDIT: Its attachment 2 that spawns with the offset)

GunEvent.OnServerEvent:Connect(function(Player, MouseTargetFilter, MouseHit, OriginPos, OriginCFrame)
	pcall(function()
		local Raycast = Ray.new(OriginPos, (MouseHit - OriginPos).Unit * GunModule.Range)
		local PartsOnRay, Position = workspace:FindPartOnRay(Raycast, Player.Character, false, true)

		local Part = Instance.new("Part", workspace)
		Part.Size = Vector3.new(0.1, 0.1, 0.1)

		local Attachment1 = Instance.new("Attachment")
		local Attachment2 = Instance.new("Attachment")
		local Beam = Instance.new("Beam", workspace)

		Part.Position = MouseHit
		Part.Anchored = true
		Part.CanCollide = false
		Part.Transparency = 1

		Attachment1.CFrame = Part.CFrame
		Attachment1.Parent = Part

		Attachment2.CFrame = OriginCFrame
		Attachment2.Parent = Player.Character[script.Parent.Parent.Parent.Name].GunParts.Origin
		
		Beam.Attachment0 = Attachment1
		Beam.Attachment1 = Attachment2
		
		Beam.Width0 = 0.2
		Beam.Width1 = 0.2
		Beam.FaceCamera = true
		
		spawn(function()
			deleteBullet(Attachment1, Attachment2, Beam, Part)
		end)

		local Humanoid = PartsOnRay.Parent:FindFirstChild("Humanoid")
		Humanoid:TakeDamage(GunModule.Damage)
	end)
end)

What is the input for origincframe?

Hey,

You think you could pre-add an asset of the bullet with the attachment and the attachment on the nozzle of the gun? Could that prevent the offset issue?

Note: The bullet can get cloned later on

I think he could just put an attachment on the gun which is the barrel. yea
(edit the attachment would have to be cloned before making the bullet)

That worked, but now the other attachment has an offset, the part spawns where the mouse clicks, but the attachment doesnt.

Edit, I managed to fix it by remaking the part and attachment and cloning it into workspace when needed.