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
game.ReplicatedStorage.UpdateCamera.OnServerEvent:Connect(function(plr,camera)
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
end)
Local Script
local RS = game:GetService("RunService")
function updatelight()
local camera = workspace.Camera.CFrame
game.ReplicatedStorage.UpdateCamera:FireServer(camera)
end
RS.RenderStepped:Connect(updatelight)