I have an avatar editor and I’m trying to set it so the camera goes in front of the player, however there is one problem.
The camera is slightly tilted, I’m assuming it’s because I’m basing it off of the head’s CFrame but I have no idea how to fix this.
Can someone please let me know how to change this code so it’ll be straight.
It’s probably because the head’s CFrame isn’t straight when applying the CFrame. You could do this relatively easily by just negating the X and Z axes of the camera’s orientation.
local headCFrame = head.CFrame
local offset = head.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(0, math.pi, 0)
local _, y = offset:ToOrientation()
local finalCFrame = CFrame.new(offset.Position) * CFrame.Angles(0, y, 0)
cam.CFrame = finalCFrame