Flashlight CFrame Problems

I’m trying to have a flashlight point to where your camera is (aka follow your screen) and the attachment (which has the lightbulb) doesn’t move, any feedback helps!
I’ve tried playing around with different ways to change the CFrame using look vectors, EulerAngles, and just changing the CFrame of the attachment to my camera, and using ToWorldSpace, all of those haven’t worked out well for me (either not working, or the light completely going off my screen when turning)

Server Script:

    local player = plr
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:WaitForChild("Humanoid")
    local hrp = character.HumanoidRootPart

    local light = hrp.Attachment.CFrame:ToWorldSpace()
local camera2 = camera:ToWorldSpace()
    local X,Y,Z = camera:ToEulerAnglesXYZ() 
local X1 = math.deg(X)
local Y1 = math.deg(Y)
local Z1 = math.deg(Z)

    light = CFrame.new(camera2.Position.X,camera2.Position.Y,camera2.Z) * CFrame.Angles(X1,0,0) * CFrame.Angles(0,Y1,0) * CFrame.Angles(0,0,Z1)


Local Script:

function updatelight()
	local camera = workspace.Camera.CFrame


Attachments follow whatever they are attached to, so you shouldn’t need to update it like this.

As far as making a part look at where the camera is looking, you can use this code on the client:

localPlayer = game.Players.LocalPlayer
currentCamera = workspace.CurrentCamera
part = workspace.Part

game["Run Service"].RenderStepped:connect(function()
	part.CFrame = CFrame.new(LocalPlayer.Character.HumanoidRootPart.Position,CurrentCamera.CFrame.p)

CFrame.new(position1,position2) will create a CFrame originating at position1 and aiming towards position2.