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

How to rotate a part like studio's rotate tool allows you to?

Asked by
kazeks123 195
7 years ago
Edited 7 years ago

While you might think that the Orientation property of the part will do the job that's not what I need, since it'll rotate that part using the global axis (axis that are oriented relative to the space and not the part).

What I need is to be able to rotate a part on its own axis when it already has a global rotation applied to it.

If you don't understand, then think of the way that the studio's rotate tool works. You can rotate the part how much you want, but its axis will still STICK to it (that is they will not change their orientation relative to the part).

That is what I need to do, but just using scripts / available properties of the part. Does anyone know how studio's rotate tool calculates the rotation for the part?

EDIT:

So as the accpeted answer states, you use CFrames muliplied by CFrames for each individual rotation (at least for me it was)

e.g. something like this:

part.CFrame = part.CFrame * CFrame.Angles(math.rad(X),0,0) * CFrame.Angles(0,math.rad(Y),0) * CFrame.Angles(0,0,math.rad(Z))

unless you want the part to have a particular rotation (like a rotation / direction that is gotten by rotating on 2 or more axis)

0
use CFrame.Angles abnotaddable 920 — 7y
0
just a problem, it should be CFrame * CFrame.Angles(math.rad(X),math.rad(Y),math.rad(Z)). This is because it is alot more efficient. abnotaddable 920 — 7y
0
Look on ArcHandles hiimgoodpack 2009 — 7y

1 answer

Log in to vote
1
Answered by
CootKitty 311 Moderation Voter
7 years ago

Yes, multiply the part's CFrame by another CFrame. This will give you local rotation.

Example:

local p = part

p.CFrame = p.CFrame*CFrame.Angles(0,math.rad(90),0)
This will rotate the part around its local y axis by 90 degrees.
0
Thankyou! This solved my problem with trying to rotate a camera! kazeks123 195 — 7y
Ad

Answer this question