Help fix buggy custom camera

I want the camera to stop spazzing out whenever i get close to an object…
heres what if currently does: robloxapp-20210919-0347029
the line of code im currently using :

hrp.CFrame = CFrame.new(hrp.Position, Vector3.new(mouse.Hit.Position.X, hrp.Position.Y, mouse.Hit.Position.Z))

nvm found it just change it into

hrp is the rootpart ofc

local LookingCFrame = CFrame.lookAt(hrp.Position, camera.CFrame:PointToWorldSpace(Vector3.new(0,0,-100000)))
				hrp.CFrame = CFrame.fromMatrix(hrp.Position, LookingCFrame.XVector, hrp.CFrame.YVector)
1 Like