How would you turn a block using CFrame in a script?
METHOD 1
The first method of rotating a cframe is by editing the angles of the cframe
CFrame has a constructor called CFrame.Angles
CFrame.Angles
is used to rotate a cframe by X, Y, and Z radians
To use it, the setup is like this:
CFrame.Angles(X_Radians, Y_Radians, Z_Radians)
So to rotate a brick, you would do this:
Brick.CFrame = Brick.CFrame * CFrame.Angles(math.rad(90), 0, 0) --This will rotate the brick 90 degrees on the X Axis
METHOD 2
The second method of rotating a cframe is by making it face a specific point
The setup for this method is like so:
CFrame.new(Origin_Vector3, Target_Vector3)
So if you wanted a brick to face a specific point, you would do this:
Brick.CFrame = CFrame.new(Brick.Position, Vector3.new(0, 0, 100)) --This would create a cframe where the origin is the position of the brick and the brick is facing the point (0, 0, 100)
Note: The origin is what the brick's position will be. So if you do something like this:
Brick.CFrame = CFrame.new(Vector3.new(0, 5, 0), Vector3.new(0, 0, 100))
That would position the brick at (0, 5, 0) and make it face (0, 0, 100)
For a full tutorial of CFrames, click here: CFrame
Hope this helped!