What's wrong with my camera manipulation script?

script.Parent.MouseButton1Click:Connect(function()
	local camera = game.Workspace.CurrentCamera
	local player = game.Players.LocalPlayer
	if camera.CameraSubject == player.Character.Humanoid then
		camera.CameraType = Enum.CameraType.Scriptable
		camera.CFrame = CFrame.new(Vector3.new(751.572, 11.136, 95.67), Vector3.new(0, 90, 0))
	end
end)

The camera isn’t rotating properly when modifying the 2nd vector.

What was the camera supposed to rotate to?

The camera is supposed to rotate 90 degrees to the left, but whatever value you put at the second vector, it stays the same.

I’m pretty sure you’re suppose to do * CFrame.Angles()

Have you tried using CFrame.Angles() ?

That’s what I did and it threw me the error posted.

Did you also use the math.rad ?

The script is above if you want to check it out by yourself.

What I would normally do is:
camera.CFrame = CFrame.new(751.572, 11.136, 95.67) * CFrame.Angles(0,math.rad(90),0))

CFrame.new Should be treated like CFrame lookAt when passing 2 Vector3 arguments.

First you want the Position Instead.

local Position = Vector3.new()--Position Here
local Angle = CFrame.Angles()--Angle here remember math.rad()!

local CFrame = CFrame.new(Position) * Angle

If you want to know more about how the function work then CFrame | Roblox Creator Documentation Document has the list of what functions you can use.

2 Likes