Trying to make a camera look at a part

Hello.
I’ve been trying to make a sort of camera system where the camera’s CFrame is completely still but I want it to look at a certain part.
for example;
https://gyazo.com/ef026e148d42aa96970bd27acbc70a60
I’ve tried to make the lookvector point to this part but it doesn’t work.
Any help would be appreciated!

2 Likes

Have you tried setting the Camera’s CFrame while using a CFrame.Angles(x, y, z) ? Also be sure to use math.rad() with the angles values inside.

I have. It didn’t work when I tried it.

Could you possibly post the line(s) that you have tried? From what I understand from your main post, setting the camera’s CFrame and rotating should be what you want.

Yes. Give me one second to post it.

repeat local a=pcall(function()wait(.1)game:GetService("StarterGui"):SetCore("TopbarEnabled",false)game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All,false)game:GetService("StarterGui"):SetCore("ResetButtonCallback",false);workspace.CurrentCamera.CameraType=Enum.CameraType.Scriptable;workspace.CurrentCamera.CFrame=CFrame.new(-11.0915213, 13.8447304, 2.6560216, 0.997564197, 0.0177008528, -0.0674715042, 1.86264515e-09, 0.967267692, 0.25375843, 0.0697547421, -0.25314033, 0.96491158)end)until(a)
local c=workspace.CurrentCamera.CFrame
function camtype(focus,target)
	if focus then
		workspace.CurrentCamera.CFrame=c*CFrame.Angles(math.rad(target.CFrame.LookVector.X),math.rad(target.CFrame.LookVector.Y),0)
	end
end
while true do
	game:GetService("RunService").Heartbeat:Wait()
	camtype(true,workspace.Part)
end

I’ve tried even more but they either errored or stayed and barely bounced.

CFrame.lookAt(Vector3, Vector3)

This CFrame construction method will create a CFrame at the location of the first Vector3, and the CFrame will look towards the position of the second Vector3.

22 Likes

Thank you! This worked wonderfully. I should’ve thought of this sooner.

1 Like

Thank you! This is very useful, as I have been confused about this for a long time.

1 Like