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

How do I set this brick to rotate to a certain position with CFrame?

Asked by
EpicLilC 150
9 years ago
game.Workspace.Brick.CFrame = CFrame.new(game.Workspace.Brick.Position, Vector3.new(0,50,0))

I was just looking at Vector3s and stuff so I wanted to find out how to make a door rotate about 180 degrees like a circle, so halfway basically. I can't figure out where i'm supposed to find the cordinates to do that, so do you just have to guess and put in random numbers until it works, or is there something i'm missing? (Also, brick is the name of my part that I want to rotate).

1 answer

Log in to vote
1
Answered by
bno23 30
9 years ago

The CFrame constructor on its own(normally) does not provide rotation. It also doesn't require a Vector3. It requires 3 numbers, x, y, and z. For example:

workspace.Brick.CFrame = CFrame.new(1, 1, 1)

This will only set the position, and it'll be at position 1, 1, 1. But you're trying to make a door spin, so you add on that CFrame.new() with a CFrame.Angles(), this uses radians, not degrees so you must use math.rad() to imput degrees into CFrame.Angles().

Example:

workspace.Brick.CFrame = CFrame.new(1, 1, 1) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(90))

That would set the bricks position to 1, 1, 1 and it's rotation to 90 degrees on the y axis.

0
I think he wants it to rotate 180 degrees around the hinges, rather than 90 degrees filling up the doorframe aquathorn321 858 — 9y
0
He can change it. bno23 30 — 9y
0
but he won't know how, since the door should be rotating around a point rather than rotating in place aquathorn321 858 — 9y
Ad

Answer this question