Need help with some of the cframe math i was working on, i didnt test to make sure the player can turn around and noticed the issue however im unsure of a good way to fix it i understand the cause being my :Inverse() though
local Torso = workspace.torso
local Head = workspace.head
local RightArm = workspace.RightArm
local LeftArm = workspace.LeftArm
local RightOffset = (RightArm.Position - Torso.Position)
local LeftOffset = (LeftArm.Position - Torso.Position)
local pitch = (RightOffset.Z - LeftOffset.Z) / 3
local roll = (LeftOffset.Y - RightOffset.Y) / 3
local TX,TY,TZ = Head.CFrame:ToEulerAnglesXYZ()
Torso.CFrame = Head.CFrame * CFrame.new(0,-0.5,0) * Head.CFrame.Rotation:Inverse() * CFrame.Angles(TX/10,0,0) * CFrame.new(0,-1.5,0) * CFrame.Angles(0, math.rad(-pitch * 10), math.rad(-roll * 10))
i have tried separating TY into its own and inverting it it came pretty close but the torso still had a weird lean to it specifically -18 on the x. any help would be really appreciated honestly.
edit: updated the code a bit still having the same issue shown