Argument 3 missing or nil

I am trying to rotate a camera, but it just writes Argument 3 missing or nil…

local UIS = game:GetService("UserInputService")
local Body = workspace["DAF XF"].Body
local Camera = workspace.Camera

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.One then
		Camera.CameraType = Enum.CameraType.Scriptable

		while Camera.CameraType == Enum.CameraType.Scriptable do
			local pos = Vector3.new(Body.Parent.DriveSeat.Position.X, Body.Parent.DriveSeat.Position.Y + 3, Body.Parent.DriveSeat.Position.Z)
			local y = Body.Parent.DriveSeat.Orientation.Y - 7
			local x = Body.Parent.DriveSeat.Orientation.X - 0
			local z = Body.Parent.DriveSeat.Orientation.Z - 0
			task.wait()
			Camera.CFrame = CFrame.new(pos, Vector3.new(CFrame.Angles(Vector3.new(0, y, 0))), Vector3.new(CFrame.Angles(Vector3.new(x, 0, 0))), Vector3.new(CFrame.Angles(Vector3.new(0, 0, z))))
		end
	end
end)

Which line is it saying has the error?

It says line 15, can you paste line 15, so I know exactly which line that is?

Camera.CFrame = CFrame.new(pos, Vector3.new(CFrame.Angles(Vector3.new(0, y, 0))), Vector3.new(CFrame.Angles(Vector3.new(x, 0, 0))), Vector3.new(CFrame.Angles(Vector3.new(0, 0, z))))v

Why are you passing a CFrame into a Vector3, that’s passing a Vector3 into the CFrame?

CFrame.Angles takes 3 radian values, not a Vector3

And passing a Vector3 into a CFrame only takes into consideration the X, Y, and Z coordinates (unless the constructor does otherwise), so your Vector3s would just become Vector3.new(0, 0, 0) since CFrame.Angles only creates a blank CFrame with modified rotational values

Ok hi again um you could just do CFrame.new(pos) * CFrame.Angles(math.rad(x),math.rad(y),math.rad(z))

3 Likes

Vector3.new(CFrame.Angles(Vector3.new(x, 0, 0)))

needs to have x,y,z not a Vector3.new

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.