Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you turn a block using CFrame?

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

5 comments

0

Use the bricks CFrame property.

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?

0

Please?

0

Hello???

0

@madman5533 I edited my answer and provided a second method of rotating a cframe

1 answer

✓ Accepted answer

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!

2 comments

0

Is there a better way of doing this because i can't get the jet exactly straight?

0

Thanks again

This discussion is preserved as it was. New answers, comments, and votes are closed.