I’d like to rotate and position a part ontop of another part using the .Position and .Orientation properties.
I can’t use CFrame or Tweening as the part is Welded and Unanchored.
I manually did the math to determine the orientation and position changes, aswell as dividing it all by 1800 to get the amount to move each time the loop runs.
What I want it to do instead. https://gyazo.com/92c1e3910a72d0c5290cf56f6ba14c66
Basically to rotate and move into the “Closed” position.
Preferable in one smooth movement, instead of rotating then moving separately.
I can provide more clearance if it is required.
Thanks!
First thing, you should be changing the X’s rotation and not the Z’s. And since this is a 90 degrees rotation, it would be easier to make a for loop, that loops from the 0 to 90, and use the i variable to add to the rotation
Then to rotate it as wanted, this way
for i = 0, 90, 1 do
wait()
local size = al.Size
local pos = al.Position
local cf = CFrame.new(pos.X, pos.Y-(size.Y/2), pos.Z)*CFrame.Angles(math.rad(i), 0, 0)*CFrame.new(0,size.Y/2,0)
--we don't set it's cframe to cf, we're just gonna use cf to determine Position and Orientation
local rx, ry, rz = cf:ToEulerAnglesXYZ()
al.Orientation = Vector3.new(math.deg(rx), math.deg(ry), math.deg(rz))
al.Position = cf.Position
end
I think this should work, if you want information on what I did visit this.