How would you change this Motor6D?

Howdy developers!

Today I come to you seeking assistance. I’m trying to solve a pretty simple issue, I just don’t know what exactly the code would be to properly execute this.

I need to take the RightShoulder Motor6D of a humanoid and move it in relation to the player’s HumanoidRootPart. So if they’re firing a gun for example, their RightShoulder will always move ‘backwards’ since the C1 or C0 is being set in relation to the root. Currently I can just do something like:

rightShoulder.C1 = rightShoulder.C1 * CFrame.new(0, 0, -1)

However that would make the arm move up rather than backwards when you’re laying down. Does anyone know how to accomplish this?

2 Likes

To accomplish this you’d need to make some extra configurations. It would take some scripting to handle this. The Motor6D needs to have a function to change it. The script/configuration you would have to use would need to connect each part of the Motor6D in order for it to function correctly.

1 Like

Stumbled on this old post, offering a solution for future searches.

The question involves understanding Object Space vs World Space. You want to translate an offset of -1 in the Z-axis of object space into a world space CFrame.

local offset = CFrame.new(0, 0, -1) -- relative to part in object space
rightShoulder.C1 = rightShoulder.C1.CFrame:toWorldSpace(offset) -- translate to world space 

Read more about this:
https://developer.roblox.com/en-us/articles/object-world-space

https://developer.roblox.com/en-us/articles/CFrame-Math-Operations#cframe-toworldspace-