- What do you want to achieve? Keep it simple and clear!
I am spawning a part based on the characters lookvector for an IKControl to attach to it. The IKControl is from the upper torso to the head and set to LookAt. The plan is to make procedural animation to face the character towards where they are looking.
- What is the issue? Include screenshots / videos if possible!
Part just simply is not going to the cameras lookvector.
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")
local head = character:WaitForChild("Head")
local cam = workspace.CurrentCamera
local Attachment = hrp:WaitForChild("R_Attachment")
ik = Instance.new("IKControl", humanoid)
ik.Target = Attachment
ik.Type = Enum.IKControlType.LookAt
ik.EndEffector = character:FindFirstChild("Head")
ik.ChainRoot = character:FindFirstChild("UpperTorso")
RS:BindToRenderStep("IKControl", 301, function()
Attachment:PivotTo(CFrame.new(cam.CFrame.LookVector.X * 50, cam.CFrame.LookVector.Y * 50, cam.CFrame.Z - 20))
end)