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

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

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)

3 comments

0

use CFrame.Angles

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.

0

Look on ArcHandles

1 answer

✓ Accepted answer

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.

1 comment

0

Thankyou! This solved my problem with trying to rotate a camera!

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