Inverse Kinematics - Robot 3Jnt Arm ~ Glitchy / inverse results

  1. What do you want to achieve?
    Inverse Kinematics robot arm.

  2. What is the issue?
    Theres seems to be some glitchy issue going on with the joints.

  3. What solutions have you tried so far?
    No solutions.

I really would appreciate some help with this, I’ve been trying to resolve this issue for ~3 days.

In the gif, point a is fixed, point b is middle, point c is the end / goal.
(https://gyazo.com/eb8258a411ae020b8b0a3946f7f212e6)

Below code calculates the joints, and where they should be.

function joints()

	pa = workspace.PointA.Position
	pb = workspace.PointB.Position
	pc = workspace.PointC.Position
	
	local dir = ( pc - pb ).Unit
	local mag = 15 -- 15 away, to restrict intersecting.

	workspace.PointB.Position = pa + ( dir * mag )
end


workspace.rootp.Changed:Connect(function(val)
	workspace.PointC.Position = workspace.rootp.Position -- rootp is the goal.
	joints()
	wait(.1)
end)