LookAt() & LookVectors

I’m trying to make a flashlight point at wherever direction the players camera is, so if I looked up the point light (in attachment) will be in the center of their screen even if they are facing up or down, it partially works (as in it moves the attachment but the light ends up off my screen when spinning left and right) however I am not that familiar with lookAt or lookvector and cannot find a solution to this, i’ve tried using mouse since my game is in first person but it seemed less effective than using the camera.
Any feedback helps!

Server Script

    local player = plr
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:WaitForChild("Humanoid")
    local hrp = character.HumanoidRootPart
    hrp.Attachment.CFrame = CFrame.lookAt(hrp.Attachment.Position, hrp.Attachment.Position + camera.LookVector


Local Script

local RS = game:GetService("RunService")
function updatelight()
	local camera = workspace.Camera.CFrame

1 Like

You could attach an invisible point light to the player’s head, and make a script that makes the head follow the mouse.

1 Like

That would work, but I don’t like the way the light bounces with the walking animation of the player’s head. But thanks for the idea!

1 Like

Maybe you change the ‘+’ to ‘*’

I suggest using the attachements WorldPosition property as it gets its position relative to the world and not its parent part.