LookVector applies as nil. How to use LookVector?

The script is supposed to check the rootPart’s CFrame lookVector and then set the camera to it, but instead it just applies it as nil. Basically, if you remove the root.CFrame.LookVector in CFrame.new(root.CFrame.LookVector), it gives the same result. As you can see, it prints the LookVector as a non-nil vector3 value.

print(root.CFrame.LookVector)
workspace.CurrentCamera.CFrame = CFrame.new(root.CFrame.LookVector)
task.wait(0.01)
print(root.CFrame.LookVector)
shiftLock(false)
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(math.rad(180), 0, 0)

Output:
image

Video: You can see how it always snaps to a default 0,0,0 CFrame orientation

That’s not how you use a LookVector. You can use CFrame.lookAlong to make the CFrame have the same LookVector.

Code:

print(root.CFrame.LookVector)
workspace.CurrentCamera.CFrame = CFrame.lookAlong(workspace.CurrentCamera.CFrame.Position, root.CFrame.LookVector)
task.wait(0.01)
print(root.CFrame.LookVector)
shiftLock(false)
workspace.CurrentCamera.CFrame *= CFrame.Angles(math.rad(180), 0, 0)

More information on CFrames:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.