Need help with calculations of Inverse Kinematics for Robot model which uses attachments and not Motor6Ds for some weird reason

Hello guys! For over a week I’m trying to make Robot which can walk and interact with objects in 3D. But problems came from prob simple place: I can’t make good code to give him possiblities to move arms, legs and etc.
I tried to use Motors6Ds, but they are not friends with code :neutral_face:. Only with animation editor. Although I maybe just stupid and did smth wrong :sweat_smile:. But that’s not min point. After failure with Motor6Ds, I decided to use RigidConstraints with Attachments. They showed better results in robot’s neck and cameras. But hands… :thinking:
Because Roblox IK works only with Motor6Ds, I need to write my own IK control. Which I did. But there’s where fun part begin: I can’t make it work properly with attachments now :sweat:
And, after 4 days of trying to fix that, I came in conclusion that I need your help.

I need to adjust code or attachments so they will follow IK calculations and move LeftArm into right place. System I did so far is pretty hard to describe here, so I’ll share place’s file:
RobotMovement-HelpWanted.rbxl (251.4 KB)

Some important notes:

  1. Code is binded to work with workspace.CameraTarget object, so calculations will try to move hand in that direction. Sadly only try…
  2. I added some comments so code will be more readable. Tell me if you need more info about what and how it working.
  3. In case if you not read entire post, I use RigidConstraints and Attachments instead of Motor6Ds and due to this InverseKinematics from roblox won’t work.
  4. When you will move workspace.CameraTarget, pink plane near robot’s left shoulder will turn and twist. It shows 2D plane on which I did calculations. Also, if CameraTarget is reachable, you will be able to see 3 colored connected dots which show results of IK raw calculations. Almost correct ones, exept the fact that there’s always 2 possible solutions to my IK method, and they may flicker.

Thanks for reading trough this giant post. I will appreciate any help! have good day! :smile: