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

Set a parts rotation Y AXIS WORLD ROTATION without affecting the other angle?

Asked by 1 year ago

So Basically I have a variable Number that goes up by 1

I HAVE A VARIABLE NUMBER THAT GOES UP BY 1

What I am trying to do is make the ROTATION OF A PART CHANGE ON A SPECIFIC AXIS

ACCORDING TO THE VARIABLE NUMBER

WITHOUT CHANGING THE OTHER AXIS

I want a part to be rotated on one axis only however if you have done rotation you would know that changing one rotation would change the other axis

meaning if I rotated only by Y Axis the rotation of other axes would change

my question is that

HOW WOULD I ROTATE it in one axis while maintaining the same axis

Similar to the world rotation handle (Default) rotation tool in Roblox Studio where it lets you rotate in one axis

I also had to make a new CFrame and rotate it because i wanted to rotate it specifically to the

Number Variable that I had.

heres how the script basically goes for now

local YRotationValueRadians = math.rad(1)

local Part = workspace.Part



Part.CFrame = CFrame.new(Part.Position) * CFrame.Angles(MaintainXAxis, YRotationValueRadians, MaintainZAxis)



-- Basically I want to only change the Y Axis

I can't really explain it more specifically but basically

For example I want a chair to rotate in one axis which is the Y Axis

yet still maintain the other axes such as the X or Z

0
im sure you can just do Part.CFrame = Part.CFrame * CFrame.Angles(0, YRotationValueRadians, 0) Puppynniko 1059 — 1y

1 answer

Log in to vote
1
Answered by
Puppynniko 1059 Moderation Voter
1 year ago
Edited 1 year ago

just times it by the part's CFrame it already doesn't affect the other axis

local Part = workspace.Part
for i = 1,100,.1 do
    Part.CFrame = Part.CFrame * CFrame.Angles(0, math.rad(i/i), 0)
    task.wait()
end

rotate on world axis

local Part = workspace.Part
for i = 1,100,.1 do
    local rx, ry, rz = Part.CFrame:ToEulerAnglesYXZ()
    Part.CFrame = CFrame.fromEulerAnglesXYZ(rx,ry + math.rad(i/i),rz) + Part.CFrame.Position
    task.wait()
end
0
I don't think you understand the problem but what I meant was doing this would reset the rotation of the x axes and the z axes of the angle what I wanted was them to be the same but still rotate Overseer_Prince 188 — 1y
0
Sure doing this would spin the object but it would reset back to 0 for the x and z axis I don't want that to happen I want the part to maintain the angle Overseer_Prince 188 — 1y
0
To be more specific think of a slightly rotated part on the x and z axis and say that I wanted to spin it on the Y Axis but not reset the other axis to 0 Overseer_Prince 188 — 1y
0
A chair that is upside down will be reverted to being up, what if I wanted to spin it upside down, what I want to do is maintain the rotation for the other axis while spinning Overseer_Prince 188 — 1y
View all comments (9 more)
0
it wont Puppynniko 1059 — 1y
0
* is basically + Puppynniko 1059 — 1y
0
so you want it to spin on the worlds axis? Puppynniko 1059 — 1y
0
Yes i want it to spin on the world axis Overseer_Prince 188 — 1y
0
Like rn I have tried like doing local X,Y,Z = workspace.Model:GetPivot():ToOrientation() Overseer_Prince 188 — 1y
0
and putting the X into math.deg(x), math.rad(i), math.deg(z) Overseer_Prince 188 — 1y
0
No luck so far tho Overseer_Prince 188 — 1y
0
i've updated it and i think it includes the solution Puppynniko 1059 — 1y
0
Lemme try it Overseer_Prince 188 — 1y
Ad

Answer this question