Hey, I have this spotlight and I want it to always aim at the cursor how can I do this?

How can I have a spotlight I put in the player’s head always aim at the player’s cursor?

here’s my current script;

local function flashlight_Toggle(check)
	if check then
		flashlightOnSFX1:Play()
		spotLight.Enabled = true
		playerGui.FlashlightGui.Enabled = true
	else
		flashlightOffSFX1:Play()
		spotLight.Enabled = false
		playerGui.FlashlightGui.Enabled = false
	end
end


local flashlightMechanic = {}

--//Main

userInputServce.InputBegan:Connect(function(input, gameProccessedEvent)
	if input.KeyCode == Enum.KeyCode.F and not gameProccessedEvent then
		if not isOn then
			isOn = true
			flashlight_Toggle(true)
		else
			isOn = false
			flashlight_Toggle(false)
		end
	end
end)

If it’s a part and a SpotLight | Roblox Creator Documentation, you can make the part face the Mouse | Roblox Creator Documentation using

CFrame.lookAt(lightPart.Position, Mouse.Hit.Position)

Is there a way I can use look vector? I dont use a part but I use an attachment this is what I have
spotLightAttachment.CFrame = CFrame.lookAt(lookVector, Vector3.new(0,0,0))

I believe it would still work with attachments. You would just have to do

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
spotLightAttachment.WorldCFrame = CFrame.lookAt(spotLightAttachment.WorldPosition, mouse.Hit.Position)