Trying to rotate X axis when the Y axis is 90 rotates the Z axis

the title explains it, other solutions ive seen on the devforum dont seem to work

heres the code that im using:

local Rotation = CFrame.Angles(math.rad(XRotationValue.Value), math.rad(YRotationValue.Value), math.rad(ZRotationValue.Value))

BuildProp.Main.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position + workspace.CurrentCamera.CFrame.LookVector * 10) * Rotation

I wrote this and it works, as in there is movement, but not sure is what your aiming at. I put the wait in there so I can see it happen, otherwise the script runs so fast that it might happen before I’ve even loaded into the game.

The setup of my BuildProp part in the map is the part is called BuildProp with a part that is a child called Main.

I don’t know what your setup is like and I’m not sure what your doing with the XRotationValue.Value, what is Value. Is XRotationValue a Variable you created and if so I don’t see it in the script.

‘’
local BuildProp = script.Parent
local XRotationValue = BuildProp.Main.CFrame.X
local YRotationValue = BuildProp.Main.CFrame.Y
local ZRotationValue = BuildProp.Main.CFrame.Z

local Rotation = CFrame.Angles(math.rad(XRotationValue), math.rad(YRotationValue), math.rad(ZRotationValue))
wait(20)

BuildProp.Main.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position + workspace.CurrentCamera.CFrame.LookVector * 10) * Rotation
‘’

What about something like this:


local BuildProp = script.Parent

task.wait(10)

local RotationY = 90
local RotationX = 90
local RotationZ = 45

BuildProp.Main.Orientation = Vector3.new(0,90,0)

task.wait(5)

if RotationY then
BuildProp.Main.BrickColor = BrickColor.new(0,255,255)
BuildProp.Main.Orientation = Vector3.new(RotationX, 90, RotationZ)

end

recreating my script wont really help with solving my problem, the problem is that whenever the Y axis on the orientation is 90, the attempting to rotate the X axis will instead rotate the Z axis

i dont want the y axis to be constantly at 90, the script im making is a building system if that helps and im using this code to allow the player to rotate objects

edit: ive managed to solve this by myself by just changing the X and Z axis before changing the Y axis:

BuildProp.Main.CFrame *= CFrame.Angles(math.rad(XRotationValue.Value), 0, math.rad(ZRotationValue.Value))
BuildProp.Main.CFrame *= CFrame.Angles(0, math.rad(YRotationValue.Value), 0)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.