My pose resetter isn't working

I want to achieve a pose resetter for R6 rigs.

However, every time that I change the Motor6Ds in my script, the Motor6Ds have a COMPLETELY different C0 and C1 than what is in the script.

This is my code:

local selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("R6 Pose Resetter V1.0")
local scriptButton = toolbar:CreateButton("Reset Pose", "Resets the pose left when you save the game while in an animation, mostly on Moon Animator 2. To use, select a rig then click Reset Pose.", "rbxassetid://89083772378352")
scriptButton.ClickableWhenViewportHidden = false
local activated = false
scriptButton:SetActive(activated)

local function MakeCFrame(positionX : number, positionY : number, positionZ : number, rotationX : number, rotationY : number, rotationZ : number) : CFrame
	return CFrame.new(Vector3.new(positionX, positionY, positionZ)) * CFrame.Angles(math.rad(rotationX), math.rad(rotationY), math.rad(rotationZ))
end

scriptButton.Click:Connect(function()
	activated = not activated
	scriptButton:SetActive(activated)
	if activated then
		activated = false
		scriptButton:SetActive(activated)
	end
	for _, v in ipairs(selection:Get()) do
		if v:IsA("Model") then
			
			for _, i in ipairs(v:GetDescendants()) do
				
				if i:IsA("Motor6D") then
					if i.Part0.Name == "HumanoidRootPart" and i.Part1.Name == "Torso" then
						i.C0 = MakeCFrame(0, 0, 0, -90, -180, 0)
						i.C1 = MakeCFrame(0, 0, 0, -90, -180, 0)
					elseif i.Part0.Name == "Torso" and i.Part1.Name == "Head" then
						i.C0 = MakeCFrame(0, 1 ,0, -90, -180, 0)
						i.C1 = MakeCFrame(0, -0.5, 0, -90, -180, 0)
					elseif i.Part0.Name == "Torso" and i.Part1.Name == "Right Leg" then
						i.C0 = MakeCFrame(1, -1, 0, 0, 90, 0)
						i.C1 = MakeCFrame(0.5, 1, 0, 0, 90, 0)
					elseif i.Part0.Name == "Torso" and i.Part1.Name == "Left Leg" then
						i.C0 = MakeCFrame(-1, -1, 0, 0, -90, 0)
						i.C1 = MakeCFrame(-0.5, 1, 0, 0, -90, 0)
					elseif i.Part0.Name == "Torso" and i.Part1.Name == "Right Arm" then
						i.C0 = MakeCFrame(1, 0.5, 0, 0, 90, 0)
						i.C1 = MakeCFrame(-0.5, 0.5, 0, 0, 90, 0)
					elseif i.Part0.Name == "Torso" and i.Part1.Name == "Left Arm" then
						i.C0 = MakeCFrame(-1, 0.5, 0, 0, -90, 0)
						i.C1 = MakeCFrame(0.5, 0.5, 0, 0, -90, 0)
					end
				end
				task.wait()
			end
			task.wait()
		end
	end
	
	print("Pose reset.")
end)


As you can see here, I showed all of the welds inside the rig before I used the pose resetter. Once I used it, the welds were sort of the opposite of the normal R6 welds.

I have tried using a function, however it still didn’t work. I have looked many times on the Creator Hub but cant seem to find anything. Can anybody tell me why it isn’t working?

Probably a bug in Studio? Sometimes the properties panel doesn’t update, weird.
What about deselecting and reselecting? Or moving the humanoid and returning it to the same position?

Also try it in a test without collaboration; if it works, it’s probably due to a collaboration bug.

I have tested it in Moon Animator and normal animator and whenever I play an animation the animation looks completely different. So, this is not a bug. I have also tried deselecting and reselecting, but there doesn’t seem to be any issue with how the script gets the selected objects.

It did not work.


If you look at this photo, the left one is a normal rig. The right one is the “pose resetted” one. The Torso Motor6D is swapped, and so is the head.

This isn’t a bug, it’s just a consequence of how there are many ways to construct a rotation matrix from Euler angles, and CFrame.Angles() doesn’t compose the rotations in the order you’re expecting. You should try using CFrame.fromOrientation() or CFrame.fromEulerAnglesYXZ(). The older CFrame.Angles() is the same as CFrame.fromEulerAnglesXYZ() which is a different order than how orientations are represented with Euler angles in the property inspector.

Note that if you need a different order from XYZ or YXZ, you can manually compose rotations yourself, obviously at the cost of some performance (wouldn’t matter for a reset, but could for an animation system), like so:

local rotation = CFrame.Angles( 0, y, 0 ) * CFrame.Angles( 0, 0, z ) * CFrame.Angles( x, 0, 0 )

If you do it like this, it doesn’t matter which of the CFrame constructors you use, because you’re manually creating and composing single-axis rotations.

1 Like

OH MY GOD, thank YOU! CFrame.fromOrientation() did not work, neither did fromEulerAnglesYXZ. They made welds like -63.253, 90, 180.

I tried your manual one,
local rotation = CFrame.Angles( 0, y, 0 ) * CFrame.Angles( 0, 0, z ) * CFrame.Angles( x, 0, 0 )

and it works! Thank you :happy1:

1 Like