Rotating Camera Without Making It Scriptable

  1. What do you want to achieve?
    Making Camera Turn Without Making It Scriptable
  2. What is the issue?!
    the camera won’t turn unless its set to scriptable
  3. What solutions have you tried so far?
    I’ve looked throught devforum,youtube and even roblox’s documentation on it
while wait() do
	--game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
	game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame*CFrame.fromOrientation(math.rad(0),math.rad(0),math.rad(5))
end

Can you explain exactly what you want?

basically i want camera to turn in z axis while also allowing player to control it

So you want the Camera to Zoom in and Out while the Player can control it?

Hey! I’d suggest viewing this post as it helped me do that!

no zoom in and zoom out would require fov change which can be done with any type of camera

Thats what the Z coordinate is

X: left - Right (Horizontal)
Y: up - Down (Vertical)
Z : Foward - Back

Incase you didn’t find it:

	local x,y,z = camera.CFrame:ToEulerAnglesXYZ()
			camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z) * CFrame.Angles(0,0,math.rad(2))

(credits)

1 Like

I would recommend the Watch CameraType, it moves the camera to follow the player and the player can control it

this is camera rotating in z axis

yes, but thats rotations, not position

i may have found a solution:

TS = game:GetService("TweenService")

game:GetService("RunService").RenderStepped:Connect(function()
local camera = workspace.CurrentCamera
TS:Create(camera, TweenInfo.new(3, Enum.EasingStyle.Linear), {CoordinateFrame = script.Parent.PrimaryPart.CFrame}):Play()
	end)

Another one i have is:

A = 0.05
game:GetService("RunService").RenderStepped:Connect(function()
	local camera = workspace.CurrentCamera
	camera.CFrame = camera.CoordinateFrame:Lerp(script.Parent.PrimaryPart.CFrame, A)
	end)
1 Like

Hey, actually I got the code that won’t keep on rotating

local camera  = game.Workspace.CurrentCamera

local UIS = game:GetService("UserInputService")
game:GetService("RunService").RenderStepped:connect(function()
	local x,y,z = cam.CFrame:ToEulerAnglesXYZ()
	if UIS:IsKeyDown(Enum.KeyCode.E) then
		camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z) * CFrame.Angles(0,0,math.rad(2))
	else 
		camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z)
	end
end)

I’d suggest lerping the camera’s CFrame for smooth results though (lmk if you need help doing that)

1 Like