Hey everyone! I’ve been trying to use the following thread to make the legs of an R15 character to follow the direction that the character is moving in, but I keep getting a following error on the 8th (edit) line of the script, “invalid argument #1 (CFrame expected, got Vector3).” Would really appreciate a solution and an explanation, because I’m not the best with CFrames.
local RunService = game:GetService("RunService")
local leftLeg = script.Parent.LeftUpperLeg.LeftHip
local rightLeg = script.Parent.RightUpperLeg.RightHip
local centerOfLegs = Vector3.new(0,-.2,0)
local rootCFrame = script.Parent.HumanoidRootPart.CFrame
local moveDirection = game.Players.LocalPlayer.Character.HumanoidRootPart.Velocity.Unit
local moveDirectionRight = CFrame.new(0, 0, 0) * moveDirection * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
local angleLeft = math.atan2(moveDirection.z, moveDirection.x)
local angleRight = math.atan2(moveDirectionRight.z, moveDirectionRight.x)
local rotationCFrame = CFrame.new(rootCFrame.Position, rootCFrame.Position + moveDirection)
RunService.RenderStepped:Connect(function()
leftLeg.C0 = CFrame.new(centerOfLegs) * CFrame.fromEulerAnglesXYZ(0, angleLeft, 0)
rightLeg.C0 = CFrame.new(centerOfLegs) * CFrame.fromEulerAnglesXYZ(0, angleRight, 0)
end)