A CFrame is a matrix representing the position & orientation of something relative to some other reference frame.
Normally, that reference frame is the origin, and the CFrame is called "in world space".
How the "math" behind it works is that result = frame * relative. If frame is the origin, i.e., CFrame.new(), then you just get relative out: CFrame.new() * relative == relative.
ASIDE: Another way to write this is frame:toWorldSpace( relative ), which may be easier to think about.
Imagine you have the CFrame CFrame.new(0, 2, 0). If you set a part to have that CFrame, it means you move it to the position (0, 2, 0).
Another way to interpret this CFrame is that it describes moving up 2 (rather than to the position (0, 2, 0)). For example, part.CFrame * CFrame.new(0, 2, 0) will be the CFrame that is 2 studs above where part.CFrame was.
Imagine you have four parts, A, B and X, Y.
A and X are placed somewhere in the world. B is somewhere nearby A.
You want Y to be in the same position relative to X that B is to A. E.g., if B is sitting on top of A, you want Y to be sitting on top of X.
If I tell you that the relative CFrame of B to A is r, then you can just use Y.CFrame = X.CFrame * r.
The obvious question is: how do we get r?
CFrames have a method, r = A.CFrame:toObjectSpace( B.CFrame ). This gets the relative CFrame from A to B.
ASIDE: This is mathematically the same as A.CFrame:inverse() * B.CFrame
Your problem
You need to pick the "base" of the two models -- what are all the CFrames relative to?
For Humanoids, the HumanoidRootPart would be a good bet, since it doesn't animate at all.
local inRoot = player.Character.HumanoidRootPart.CFrame
local outRoot = fake.HumanoidRootPart.CFrame
for _, part in pairs(fake:GetChildren()) do
if part:IsA("BasePart") then
local correspond = player.Character[ part.Name ].CFrame
part.CFrame = outRoot * inRoot:toObjectSpace(correspond)
end
end
3 comments
Do this: FakeArm.CFrame = CFrame.new(FakeArm.CFrame.p,RealArm.lookVector)
^^ nope, it just tilts the body, rather than the individual parts themselves
You want them to all have the same orientation relative to the torso.