CFrame being different on other angles

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    For it to be the same no matter what direction I’m looking.
  2. What is the issue? Include screenshots / videos if possible!
    For some reason the weapon goes upside down when turning the camera at a certain angle, then goes back up also at a certain angle.
local x,y,z = right.Real.CFrame:ToEulerAnglesXYZ()
right.Holding.Value.CFrame =,left.Real.Position)*CFrame.Angles(0,math.rad(-90),0)*CFrame.Angles(z,0,0)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried doing the + Z in other places to no avail.

It probably to do with it being not in the objects space but in world space

Try converting it into object space


Try this

local x,y,z = right.Real.CFrame:ToEulerAnglesXYZ()
local rightParent = right.Real.Parent
local leftParent = left.Real.Parent

local rightCFrame = right.Real.CFrame - rightParent.CFrame
local leftCFrame = left.Real.CFrame - leftParent.CFrame

right.Holding.Value.CFrame = rightParent.CFrame:toObjectSpace(rightCFrame) *,left.Real.Position) * CFrame.Angles(0,math.rad(-90),0) * CFrame.Angles(z,0,0)

This didn’t work and sent the object thousands of studs away from where it should be.
I also had to re-write a lot of it as none of it worked otherwise, its probably my fault that it doesn’t work but here’s the code so you can probably spot the error:

local x,y,z = right.Real.CFrame:ToEulerAnglesXYZ()
right.Holding.Value.CFrame = right.Real.CFrame:ToObjectSpace(right.Holding.Value.CFrame) *,left.Real.Position) * CFrame.Angles(0,math.rad(-90),0) * CFrame.Angles(z,0,0)

By the way left/right.Real parent is left and right, and left/right are configs.