CFrame LookAt Behaving Oddly

Hi!

So I’m trying to create a very, very simple script and I can’t get my head around why it’s not working.

Essentially I want to position a camera and make it look somewhere. Sounds easy! I’ve done it before loads of times.

Basically it’s just not working, the camera is being moved to somewhere random in the sky (same place each time) and looking at somewhere just as random.

This is the positional layout of the bricks I’m interacting with so that’s not the issue.

You can see a video of the result here:

Here is the code

while wait(1) do
    camera.CFrame = CFrame.lookAt(StartPosition.Position, LookAt.Position)
	wait(1)
end

Am I missing something obvious?

Note: I have also tried the depricated CFrame.new(position, lookAt) constructor with no joy.
Note: There are multiple different selectors for StartPosition and LookAt hence why there are jumps in the video, the code provided is the snippet where the issue lies

1 Like

If the camera is not Scriptable or Custom, then the camera script (which takes care of right-click to rotate etc.) will discard the direction data and make the camera face the Focus of the camera (which is a CFrame, but only its position data is used)

So if that’s the case, then you can accomplish this by

camera.CFrame = StartPosition.CFrame
camera.Focus = LookAt.CFrame

If your camera mode is Scriptable or Custom, then I have no clue why it’d do what you described.