Hey, so I have an Inverse Kinematics script and I am trying to make it so the Head (Neck Motor6D) follow the TargetPart, the UpperTorso (Waist Motor6D) follow the Head and the LowerTorso (Root Motor6D) follow the UpperTorso. But it’s not working the way I want it to.
Problem: https://imgur.com/tzNNURb
Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local Target = workspace:WaitForChild("Target1234") local Character = script.Parent local HumRootPart = Character:WaitForChild("HumanoidRootPart") local Neck = Character:WaitForChild("Head"):WaitForChild("Neck") local Waist = Character:WaitForChild("UpperTorso"):WaitForChild("Waist") local Root = Character:WaitForChild("LowerTorso"):WaitForChild("Root") local WaistC0 = Waist.C0 local NeckC0 = Neck.C0 local UpperLength = math.abs(Neck.C1.Y) + math.abs(Waist.C0.Y) local LowerLength = math.abs(Waist.C1.Y) + math.abs(Root.C0.Y) + math.abs(Root.C1.Y) local solveModule = ReplicatedStorage:WaitForChild("SolveIK") local solveIK = require(solveModule) RunService.Heartbeat:Connect(function() local HumRootPartCFrame = HumRootPart.CFrame * NeckC0 local TargetPosition = Target.Position local planeCF, shoulderAngle, elbowAngle = solveIK(HumRootPartCFrame, TargetPosition, UpperLength, LowerLength) Neck.C0 = HumRootPart.CFrame:toObjectSpace(planeCF) * CFrame.Angles(shoulderAngle, 0, 0) Waist.C0 = WaistC0 * CFrame.Angles(elbowAngle, 0, 0) end) RunService.Stepped:Connect(function() Neck.Transform = CFrame.new() Waist.Transform = CFrame.new() Root.Transform = CFrame.new() end)
Note: I am not good with manipulating Motor6Ds. Another thing is that I am trying to make a VR Script (All the other ones out there aren’t good in my opinion). Final thing, the ServerScript is located inside a dummy that is inside the workspace. Should look something like this (game.Workspace.Dummy.Script).