How would I create a Tool Grip CFrame using an existing rig?

Hello,

I would like to preface this by saying that I am aware of tool grip editing plugins and I’m not looking for those, I’m looking for a way to do this using code.

I have an existing R6 model and an existing handle for my tool:

image

Note: This is not an existing player model holding a tool. This is an NPC with a weapon model which is not a tool.

I’m aware that the grip is relative to the right arm. What I want to figure out:
I want to write a line of code (or a few lines) which creates a CFrame value for a tool grip that will result in being able to hold the tool the way it appears in the picture.

In other words, I’m trying to create a tool grip from an existing tool and an existing right arm in workspace.

I have tried many different lines of code and none of them give accurate results; some are close, but off by a stud or two in position and a few degrees in rotation.

I don’t want to list the several attempts I’ve made, but here are a couple examples of failed attempts:

tool.Grip = rightArm.CFrame:Inverse() * weapon.CFrame

tool.Grip = (rightArm.CFrame:Inverse() * CFrame.Angles(math.pi/2,0,0) + rightArm.CFrame.UpVector * -1) * weapon.CFrame

If anyone could help me with this then I would greatly appreciate it. Relative CFrames are a weakness of mine, or maybe tool grips and their welds are just weird, but I’m not sure what I’m missing here.

1 Like