I want the camera to rotate on the parts LOCAL axis. I believe :toEulerAngles is on the global axis though. Here's the problem. When I rotate the brick on the z axis, everything's fine. But as it starts rotating on the Y, the camera seems to change when it shouldn't, because it should only rotate according to the parts local Z axis.
local x,y,z = workspace.Part.CFrame:toEulerAnglesXYZ() print(y) roll = y game.Workspace.CurrentCamera:SetRoll(roll)
You can do this by simply setting the CoordinateFrame of the Camera to the part's CFrame. the CameraType would have to be Scriptable and the CameraSubject will have to be that part.
local cam = workspace.CurrentCamera local reference = workspace.Part cam.CameraType = 'Scriptable' cam.CameraSubject = reference while wait() do cam.CoordinateFrame = reference.CFrame end
This would theoretically match every angle of the part with the Camera. But just be sure, let's use the CFrame operator that takes in two arguments, one as the Vector3 origin, and the second as the Vector3 lookat.
local cam = workspace.CurrentCamera local reference = workspace.Part cam.CameraType = 'Scriptable' cam.CameraSubject = reference while wait() do cam.CoordinateFrame = CFrame.new((reference.CFrame * CFrame.new(0,5,5)).p,reference.CFrame.p) end