Rigging a part to a player via motor6D by script messes up where the center of the object is

The code is fairly simple and straightforward, but I must be missing an important step.

part.Parent = character
local motor = Instance.new('Motor6D')
motor.Parent = part
motor.Part0 = character.PrimaryPart
motor.Part1 = part
motor.C0 = character.PrimaryPart.CFrame:inverse()
motor.C1 = part.CFrame:inverse()
part.Anchored = false

If I am to run this through the command bar with an NPC and open the animation editor, I’m met with something like this:

As you can see, it appears to rotate around the 0, 0, 0 world position instead of the center of the part.

You’re probably going to tell me to just use a plugin. The problem with this is that there is no way to do this when a player is in the game. The other problem with using a plugin is that when I try to use this rigging method with the plugin-created rig, the animation will play offset to the way I animated it because of this issue.

So my question is: What do I have to do to rig it in the same way the plugins would via script?

3 Likes