Isometric Camera Rotation using a key press

I have this script for an isometric camera, but I want to know how to rotate it by 45 degrees on the X axis multiple times to the players desired camera orientation.

--//Settings//--
local zoom = 100
local FieldOfView = 9

--//Do not edit unless you know what you're doing//--
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = game.Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Custom

local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
	Camera.FieldOfView = FieldOfView
	if Character then
		if Character:FindFirstChild("Head") then
			game:GetService("SoundService"):SetListener(Enum.ListenerType.ObjectCFrame, Character.Head)
			Camera.CFrame =
				CFrame.new(Vector3.new(Character.Head.Position.X + zoom, Character.Head.Position.Y + 80, Character.Head.Position.Z + zoom), Character.Head.Position)
		end
	end
end)

Iā€™d find a way to preserve the real angle the camera is at in regards to rotation and then round it and set the camera to that angle:
math.round(realAngle * (1/45))/(1/45)

You could get mouse inputs and do something with the mouse delta each frame to get the current angle, and then round that.

1 Like

You can make an angle variable and add math.pi/4 to it whenever the key is pressed.

This is assuming you understand UserInputService.

Literally just multiply the camera CFrame by CFrame.Angles(math.rad(45), 0, 0)