Need help with making a beam from a part to camera

Hello there
I need help with making a beam connect from a block to the camera. The beam does not connect to camera making it look really weird. I have a video of the problem that will explain it better.

I’ve tried to change the position of the attachments, but still dosent work.
The code is here:

local player = game.Players.LocalPlayer 
local mouse = player:GetMouse() 
local camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local target 
local down
local camPart ="Part", workspace)
camPart.Anchored = true
camPart.CanCollide = false
camPart.Transparency = 1

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

-- get local player
local localPlayer = Players.LocalPlayer

-- create beam
local beam ="Beam")
beam.Segments = 1
beam.Width0 = 0.2
beam.Width1 = 0.2
beam.Color =,255,255))
beam.FaceCamera = true

-- create attachments
local attachment0 ="Attachment")
local attachment1 ="Attachment")
beam.Attachment0 = attachment0
beam.Attachment1 = attachment1

-- get the mouse
local mouse = localPlayer:GetMouse()

	if mouse.Target ~= nil and mouse.Target.Locked == false then
		target = mouse.Target 
		mouse.TargetFilter = target 
		down = true 
		local gyro ="BodyGyro")
		gyro.Name = "Gyro"
		gyro.Parent = target 
		gyro.MaxTorque =, 500000, 500000)
		local force ="BodyPosition") 
		force.Name = "Force" 
		force.Parent = target
		force.MaxForce =, 100000, 100000)

	if down == true and target ~= nil then 
		camPart.Position = camera.CFrame.Position + (mouse.UnitRay.Direction * 10)
		target.Gyro.CFrame = target.CFrame --this is to keep rotation
		target.Force.Position = camera.CFrame.Position + (mouse.UnitRay.Direction * 20)
		beam.Parent = target
		attachment0.Parent = target
		attachment1.Parent = camPart
		-- make sure the character exists
		local character = localPlayer.Character
		if not character then
			-- disable the beam
			beam.Enabled = false
		-- make sure the head exists
		local head = character:FindFirstChild("Head")
		if not head then
			-- disable the beam
			beam.Enabled = false
		-- enable the beam
		beam.Enabled = true
		-- define origin and finish
		local origin = target.Position
		local finish = camPart.Position
		-- move the attachments 
		attachment0.Position = origin
		attachment1.Position = finish

	game.ReplicatedStorage.SetPartPosition:FireServer(target, target.Position)
	if target then
		if target:FindFirstChild("Gyro") or target:FindFirstChild("Force") then --check if there was a force
	down = false
	mouse.TargetFilter = nil
	target = nil 
	beam.Enabled = false

Please help me if you can! :slight_smile:

You should try it from part to player’s head instead.

I’ve tried but it still dosen’t work.

I’ve fixed the problem by not changing the position of the attachments! Thanks for the help! :slight_smile: