fromEulerAnglesXYZ issues

I started coding about a week ago and thought I would try and make it so that when you press a button the camera turns 90 degrees for a shop GUI, the problem is that if I put in 90 degrees I get this

and if I put in 89 degrees I get this

the script is:

local wall = game.Workspace.Wall
local on = false
local camera = game.Workspace.CurrentCamera

function Click()
	if on == false then
		on = true
		camera.CameraSubject = wall
		camera.CameraType = Enum.CameraType.Scriptable
		camera.FieldOfView = 70

		camera.CFrame = CFrame.new(wall.Position) * CFrame.new(-25, -5, 25)
		camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, 90, 0)
	else
		on = false
		camera.CFrame = CFrame.new(wall.Position) * CFrame.new(0, -5, 25)
		camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 0)
	end
end

script.Parent.MouseButton1Click:Connect(Click)

any idea why this is?

1 Like

The angle measurements for the rotation are in radians. If you want to convert them from degrees to radians then replace this

CFrame.fromEulerAnglesXYZ(0, 90, 0)

with this

CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
3 Likes