Hello,
So I watched this video about the FABRIK method on IK FABRIK (Inverse kinematics) - YouTube
And I thought I understand it but when I started scripting this happened

Place File:
rbxl.rbxl (22.5 KB)

Script:

``````local a = workspace.a
local b = workspace.b
local c = workspace.c
local pos = workspace.pos
local function gep(e,ee)
local er
if ee==0 then
er = e.CFrame+e.CFrame.RightVector*-(e.Size.X/2)
elseif ee==1 then
er = e.CFrame+e.CFrame.RightVector*(e.Size.X/2)
end
return er.Position
end
while wait() do
local p0 = gep(a,0)
local p1 = gep(a,1)
local p2 = gep(b,1)
local p3 = gep(c,1)
repeat
wait()
p3 = (p2-pos.Position).Unit*c.Size.X
p2 = (p2-p3).Unit*c.Size.X
p1 = (p1-p2).Unit*b.Size.X
p1 = (p0-p1).Unit*a.Size.X
p2 = (p1-p2).Unit*b.Size.X
p3 = (p2-p3).Unit*c.Size.X
until (p3-pos.Position).Magnitude>=(a.Size.X+b.Size.X+c.Size.X)-.01

local a0 = Instance.new("Part",workspace)
local a1 = Instance.new("Part",workspace)
local a2 = Instance.new("Part",workspace)
local a3 = Instance.new("Part",workspace)
a0.Size=Vector3.new(.5,.5,.5)
a1.Size=Vector3.new(.5,.5,.5)
a2.Size=Vector3.new(.5,.5,.5)
a3.Size=Vector3.new(.5,.5,.5)
a0.Anchored=true
a1.Anchored=true
a2.Anchored=true
a3.Anchored=true
a0.Position=p0
a1.Position=p1
a2.Position=p2
a3.Position=p3
print(a0.Position)
print(a1.Position)
print(a2.Position)
print(a3.Position)
a.CFrame=CFrame.new(p0-p1)
b.CFrame=CFrame.new(p1-p2)
c.CFrame=CFrame.new(p2-p3)