Lock on glitching

The objective of this script is to make a “lock on feature”
it does it for the most part but then, this happens
robloxapp-20210605-1159530.wmv (1.9 MB)
I tried changing it but didn’t get anywhere :<

Code:

while FocusingOn and CChar do
		local B = FocusingOn.Focus.Position --It's often a humanoidRootPart
		local A = CChar.HumanoidRootPart.Position
		local Offset = Vector3.new(0,5,0)
		local V = B + ((A + Offset) - B).Unit * ((A - B).Magnitude + LocalPlayer.CameraMinZoomDistance)
		
		Camera.CFrame = CFrame.new(V, B)
		
		
		
		RunService.Stepped:Wait()
	end

(CChar means Current char)

If you don’t mind me asking your trying to make the camera look at a certain point, correct with some position other than where it is?

1 Like

Oh I see what your problem is, try checking if the direction to where your trying to look at is straight up or down then just don’t run the code for that frame.

1 Like

uhh do you know how I get the direction
(I think it’s CFrame.LookVector.Y but not sure ;w;)

TYSM found the solution :DDD
robloxapp-20210605-1409377.wmv (1.3 MB)