How do I edit a Motor6D’s C0 and C1 and keep the animations looking the exact same even though the weld is completely different, I’ve spent days trying to make a script that edits the anim saves but my math is just completely wrong.
This is what I was able to get done, but its not fully correct, and its missing C1 support, I don’t know if there are other scripts that do what I am trying to accomplish or not
-- Customizable Settings --
local Rig: Model = script.Parent.RapierRig
local Handle: Motor6D = Rig["Right Arm"].Motor6D
local NewWeld: CFrame = CFrame.new(0, -1, 0) * CFrame.fromOrientation(-math.rad(90), -math.rad(180), 0) -- Make sure to add math.rad for every angle or if you're fancy do the angle * (math.pi/180)
local CustomCopyLocation = nil -- Default is workspace.AdjustedRigs (Creates the folder if it doesn't exist)
-- Script Variables --
local OldWeld = Handle.C0
local OldRX, OldRY, OldRZ = OldWeld:ToEulerAnglesXYZ()
local NewRX, NewRY, NewRZ = NewWeld:ToEulerAnglesXYZ()
local DeltaCFrame = CFrame.new(NewWeld.X - OldWeld.X, NewWeld.Y - OldWeld.Y, NewWeld.Z - OldWeld.Z) * CFrame.fromOrientation(NewRX - OldRX, NewRY - OldRY, NewRZ - OldRZ)
local DeltaRX, DeltaRY, DeltaRZ = DeltaCFrame:ToEulerAnglesXYZ()
local HandleName = "Handle" -- You never need to change this except for really small use cases
local NewRig, CopyLocation, NewHandle
-- Iniitalize Copy --
NewRig = Rig:Clone()
local CurrentParent = Handle.Parent
local NewHandleParentList = {CurrentParent.Name}
NewHandle = NewRig
if CurrentParent.Parent ~= Rig then
repeat
CurrentParent = CurrentParent.Parent
table.insert(NewHandleParentList, CurrentParent.Name)
until CurrentParent.Parent == Rig
end
table.insert(NewHandleParentList, Handle.Name)
for i = 1, #NewHandleParentList do
NewHandle = NewHandle[NewHandleParentList[i]]
end
if CustomCopyLocation ~= nil then
CopyLocation = CustomCopyLocation
else
if workspace:FindFirstChild("AdjustedRigs") == nil then
CopyLocation = Instance.new("Folder")
CopyLocation.Name = "AdjustedRigs"
CopyLocation.Parent = workspace
else
CopyLocation = workspace.AdjustedRigs
end
end
if Rig:FindFirstChild("AnimSaves") == nil or #Rig.AnimSaves:GetChildren() == 0 then
warn("There are no Animations in "..Rig.Name)
return
end
-- Update Animations --
for _, Animation in pairs(NewRig.AnimSaves:GetChildren()) do
if #Animation:GetChildren() == 0 or Animation.ClassName ~= "KeyframeSequence" then
continue
end
for _, Keyframe in pairs(Animation:GetChildren()) do
if #Keyframe:GetChildren() == 0 or Keyframe.ClassName ~= "Keyframe" or Keyframe:FindFirstChild("HumanoidRootPart") == nil or Keyframe.HumanoidRootPart:FindFirstChild("Torso") == nil or Keyframe.HumanoidRootPart.Torso:FindFirstChild("Right Arm") == nil or Keyframe.HumanoidRootPart.Torso["Right Arm"]:FindFirstChild(HandleName) == nil then
continue
end
local HandleKeyframe = Keyframe.HumanoidRootPart.Torso["Right Arm"][HandleName]
local OldKeyframePosition: CFrame = HandleKeyframe.CFrame
local OldKRX, OldKRY, OldKRZ = OldKeyframePosition:ToEulerAnglesXYZ()
HandleKeyframe.CFrame = CFrame.new(
OldKeyframePosition.X - DeltaCFrame.X,
OldKeyframePosition.Y - DeltaCFrame.Y,
OldKeyframePosition.Z - DeltaCFrame.Z
) * CFrame.fromOrientation(
OldKRX - DeltaRX,
OldKRY - DeltaRY,
OldKRZ - DeltaRZ
)
end
end
NewHandle.C0 = NewWeld
NewRig.Parent = CopyLocation