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

Moving a part on ITS AXIS?

Asked by
Scarious 243 Moderation Voter
8 years ago

So....

I tried to make a part move on it's axis, not the worlds axis using a script and....

ERROR

Yes, I used CFrame... but I'm really bad at using lookVector, I know you do something with it... but what?

DO NOT POST A WIKI LINK TO CFRAME OR LOOKVECTOR WHICH DOESN'T GO ANYWHERE

2 answers

Log in to vote
2
Answered by
Link150 1355 Badge of Merit Moderation Voter
8 years ago
Edited 8 years ago

No need to use lookVector.

01local function translate(part, x, y, z)
02    -- Multiplying two CFrames returns their composition.
03    -- Their rotations and THEN their positions are added.
04 
05    part.CFrame = part.CFrame   -- CFrame with part's rotation and position
06        * CFrame.new(x, y, z)   -- CFrame with no rotation (offset)
07end
08 
09 
10translate(script.Parent, 2, 0, 0)
Ad
Log in to vote
0
Answered by
Scarious 243 Moderation Voter
8 years ago
1local function translate(part, x, y, z) 
2part.CFrame = part.CFrame   * CFrame.new(x, y, z)
3end
4 
5 
6translate(workspace.Particual2, workspace.Particual.Position.X, workspace.Particual.Position.Y, workspace.Particual.Position.Z)

And here's the list!

-> workspace -> Particual1 -> Particual2

Answer this question