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.

local function translate(part, x, y, z)
    -- Multiplying two CFrames returns their composition.
    -- Their rotations and THEN their positions are added.

    part.CFrame = part.CFrame   -- CFrame with part's rotation and position
        * CFrame.new(x, y, z)   -- CFrame with no rotation (offset)
end


translate(script.Parent, 2, 0, 0)
Ad
Log in to vote
0
Answered by
Scarious 243 Moderation Voter
8 years ago
local function translate(part, x, y, z)  
part.CFrame = part.CFrame   * CFrame.new(x, y, z)
end


translate(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