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

How can I make an object keep its rotation while using CFrame to move it?

Asked by 6 years ago

I'm trying to make a block move with CFrame, and it moves but it also changes the rotation. How can I make it still move but keep the rotation it's set at? Do I have to use eular angles? This is most of the script:

local curtain1Open = {CFrame = CFrame.new(181.278, 9.032, 130.809)}
local curtain2Open = {CFrame = CFrame.new(-26.57, 3.99, -8.56)}
local curtain1Close = {CFrame = CFrame.new(191.071, 9.032, 130.809)}
local curtain2Close = {CFrame = CFrame.new(-18.91, 3.99, -8.56)}
local tween1open = TweenService:Create(curtain1,tweeningInformation,curtain1Open)
local tween1close = TweenService:Create(curtain1,tweeningInformation,curtain1Close)
local tween2open = TweenService:Create(curtain2,tweeningInformation,curtain2Open)
local tween2close = TweenService:Create(curtain2,tweeningInformation,curtain2Close)
0
OML SAME QUESTION O_O free upvote greatneil80 2647 — 6y

1 answer

Log in to vote
2
Answered by 6 years ago

In order to keep the rotation, you simply have to subtract the Part's CFrame by its position and then multiply by this value (to keep the rotation while not moving the part) Here's an example so you can understand better: Let's say you have a Part in workspace called "Part", here's how you do it:

local Part = workspace.Part
local Rotation = Part.CFrame - Part.Position
Part.CFrame = CFrame.new(0,10,0) * Rotation -- change the position to whatever you want
Ad

Answer this question