I’m making an animation plugin that lets animate multiple rigs at once. But when i try to rotate limbs specifically the arms and legs the x and z axis are swapped i’ve tried fixing it but it doesn’t work. On the torso and head the x axis is flipped and the y and z axis are swapped.
Here is the function to make the rig animatable
local function RigRender(Rig : Model)
local F = Instance.new("Folder", game.Workspace)
F.Name = "RigParts"
local D = Instance.new("Folder", F)
D.Name = "Detection"
local P = Instance.new("Folder", F)
P.Name = "PartControllers"
local Motors = {}
local Oris = {}
local Poss = {}
for _, a in pairs(Rig:GetChildren()) do
if a:FindFirstChildOfClass("Motor6D") then
for v, e in pairs(a:GetChildren()) do
if e:IsA("Motor6D") then
local m : Motor6D
m = e
local i = e.Part1
local BaseOri = m.C1.Rotation
local BasePos = m.C1.Position
table.insert(Motors, m)
table.insert(Oris, BaseOri)
table.insert(Poss, BasePos)
local Detect = Instance.new("Part", D)
Detect.Massless = false
Detect.Name = i.Name
Detect.Size = i.Size + Vector3.new(0.01,0.01,0.01)
Detect.Transparency = 1
local Part = Instance.new("Part", P)
Part.Massless = true
Part.Name = i.Name
Part.Size = Vector3.new(0.1,0.1,0.1)
Part.Transparency = 1
Part.Position = i.Position + m.C1.Position
Part.CFrame *=
m.C1.Rotation*m.Part1.CFrame.Rotation*m.C0.Rotation*m.Part0.CFrame.Rotation
local pPos = Part.Position
local pOri = Part.CFrame.Rotation
wait(0.01)
Part.Changed:Connect(function(prop)
if prop == "Orientation" then
m.C1 = CFrame.new(m.C1.Position)
m.C1 *= BaseOri*(pOri*Part.CFrame.Rotation:Inverse())
elseif prop == "Position" then
local Ori = m.C1.Rotation
m.C1 = CFrame.new(BasePos+(pPos-Part.Position))
m.C1 *= Ori
end
end)
local w = Instance.new("Weld", Detect)
w.Part0 = i
w.Part1 = Detect
end
end
end
end
repeat wait(0.01) until not Opened
for i = 1, #Motors do
local a = Motors[i]
a.C1 = CFrame.new(Poss[i])
local BaseOri = Oris[i]
a.C1 *= BaseOri
end
F:Destroy()
end