CFramed Camera Glitches

I am trying to create a smooth isometric camera. With my script, the camera appears very glitchy. I believe that the camera appears glitchy due to the wait() in the code, however, without waiting, the script crashes the game and I’m not sure of any other solution.

This is my first time working with CFrames and I’m not sure how to make the camera move smoother and I would appreciate it if anyone could point me in the right direction. :slight_smile:

Screen recording

My code (Local Script in Starter Player Scripts)

local Camera = game:GetService("Workspace"):WaitForChild("Camera")
local LPlayer = game:GetService("Players").LocalPlayer

wait()

Camera.FieldOfView = 40
Camera.CameraType = Enum.CameraType.Scriptable

while true do
	Camera.CFrame = CFrame.new(
		-- Position player's camera 15 studs away from their head in each direction
		LPlayer.Character:WaitForChild("Head").Position + Vector3.new(15, 15, 15),
		
		-- Point player's camera towards their head
		LPlayer.Character:WaitForChild("Head").Position
	)
	wait()
end

Thanks again! :slightly_smiling_face:

I believe that a better way to implement this would be to use the CameraOffset property of the humanoid class.
Also, please try not to use while loops in situations like these as your scripts could be choppy (like this) and may pause the current thread. It’s much more efficient to use events like “Changed” or “RunService.Heartbeat”

https://developer.roblox.com/en-us/api-reference/property/Humanoid/CameraOffset

1 Like

Used your suggestions and it works great, thanks a ton! :smiley:

1 Like