-- connect to RenderStepped (update every frame)

RunService.RenderStepped:Connect(function()
 
	-- make sure the character exists
	local character = localPlayer.Character
	if not character then
		-- disable the beam
		beam.Enabled = false
		return
	end
 
	-- make sure the head exists
	local head = character:FindFirstChild("Head")
	if not head then
		-- disable the beam
		beam.Enabled = false
		return
	end
 
	-- enable the beam
	beam.Enabled = true
 
	-- define origin and finish
	local origin = head.Position
	local finish = mouse.Hit.p
 
	-- move the attachments 
	attachment0.Position = origin
	attachment1.Position = finish
end)
