Workspace CFrame into Keyframe CFrame

I’m trying to make a script based on converting poses in workspace to keyframes in an animation.

Right now, I’m having trouble getting the formula for converting the CFrame into the correct place in the animation, because if I just set the pose .CFrame to the CFrame I want, it doesn’t display the poses in workspace properly. If I could get help finding the correct formula for the script that would be appreciated,

-- This is what I have to far:
-- The array is sorted like {Head.CFrame, LeftArm.CFrame, RightArm.CFrame, Torso.CFrame, LeftLeg.CFrame, RightLeg.CFrame}

for keyframeindex, arrayofcframes in ipairs(keyframes) do
		local keyframeindexmodel = folder:FindFirstChild(keyframeindex)		
		local keyframe = Instance.new("Keyframe")
		keyframe.Time = animationtime
		keyframe.Name = tostring(keyframeindex)
		local rootPose = Instance.new("Pose")
		rootPose.Name = "HumanoidRootPart"
		rootPose.Weight = 0
		keyframeSequence:AddKeyframe(keyframe)
		keyframe:AddPose(rootPose)			
		
		local torsopart = keyframeindexmodel:FindFirstChild("Torso")		
		local torsopose = Instance.new("Pose")
		torsopose.Name = torsopart.Name
		torsopose.Weight = 1
		torsopose.CFrame = arrayofcframes[4] --need help with this line
		rootPose:AddSubPose(torsopose) 
		for arrayindex, cframe in ipairs(arrayofcframes) do
			if cframe ~= nil then						
				local bodypart = keyframeindexmodel:FindFirstChild(bodyparts[arrayindex][2])				
				if bodypart.Name ~= "Torso" then		
					local pose = Instance.new("Pose")
					pose.Name = bodypart.Name
					pose.Weight = 1
					local joint = getJointBetween(keyframeindexmodel:FindFirstChild("Torso"), bodypart)					
					pose.CFrame *= joint.Transform:Inverse() * joint.C1:Inverse() --and this line
					rootPose:AddSubPose(pose) 
				end
			end									
		end
		animationtime += .016
	end
	
	return keyframeSequence
end

I basically want to do this but backwards:

late post

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.