Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How do you turn a block using CFrame?

Asked by 10 years ago

How would you turn a block using CFrame in a script?

0
Use the bricks CFrame property. GoldenPhysics 474 — 10y
0
Yea, i know that. I need to know how to manipulate the CFrame property in order for me to turn it. How do i do it? QuantumScripter 48 — 10y
0
Please? QuantumScripter 48 — 10y
0
Hello??? QuantumScripter 48 — 10y
0
@madman5533 I edited my answer and provided a second method of rotating a cframe TurboFusion 1821 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

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!

0
Is there a better way of doing this because i can't get the jet exactly straight? QuantumScripter 48 — 10y
0
Thanks again QuantumScripter 48 — 10y
Ad

Answer this question