Argument 3 missing or nil

Hi! This might be a simple issue for u but I don’t get it.
So here is my problem, I get “Argument 3 missing or nil” error because of this part of code:

CFrame.Angles((player.Character:FindFirstChild("HumanoidRootPart").CFrame.lookVector - mouse.Hit.p).Unit)

However in the output it prints the Vector3 value, example: 0.0292050056, 0.918657899, 0.393973082
Here is the full code, in case you need it:

local player =  game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local waist = player.Character:FindFirstChild("Waist", true)
local defPos = waist.C0.Y
game:GetService("RunService").RenderStepped:Connect(function()
	print((player.Character:FindFirstChild("HumanoidRootPart").CFrame.lookVector - mouse.Hit.p).Unit)
	waist.C0 = CFrame.new(0, defPos, 0) * CFrame.Angles((player.Character:FindFirstChild("HumanoidRootPart").CFrame.lookVector - mouse.Hit.p).Unit)
end)

Thanks for help!

CFrame.Angles takes three arguments, not one. You’ve provided 1 Vector3 argument, and have provided nothing (aka nil) for both second and third arguments.

You could do:

local unit = (player.Character:FindFirstChild("HumanoidRootPart").CFrame.lookVector - mouse.Hit.p).Unit
local cframe = CFrame.Angles( unit.X, unit.Y, unit.Z )

though I struggle to see a use case for treating the unit vector as radian inputs to the Angles constructor. What is it you’re trying to achieve?

7 Likes

Thank u for ur reply, I am trying to rotate waist to the direction of the mouse, but its obviously broken, because I am new to this kind of stuff… p.s. dont send me a code or sth like this, bc I am trying to do it by myself

No problem. You’ll need some trigonometry to determine angles between vectors. Best of luck, and experimenting and working things out for yourself is my preferred method too.

just a quick question, do u know by any chance how to connect two dots with a vector, for example the position of root and mouse position?