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

Changing Vector Direction?

Asked by
steev 0
10 years ago

I have made a model called "Gate" and it moves up and down successfully. My question is how would you change the direction of the vector to move left or right?

local model = game.Workspace["Gate"]; -- The model you want to move up
local increment = 0.5 --The amount you want it to go up by each time
local max = 10 --The studs you want to go up by
local Button = script.Parent.ClickDetector --Change this to the ClickDetector.
local closed = true
local isMoving = false

function onClick()
    if isMoving == false then
        isMoving  = true
            if closed then
                move = increment 
            else 
                move = -increment 
            end 
            closed = not closed
            for i=1, max/increment do
                model:TranslateBy(Vector3.new(0,move,0));
            wait(1/60)
            end
        isMoving = false
    end
end

Button.MouseClick:connect(onClick) ;

1 answer

Log in to vote
0
Answered by
Andalf 100
10 years ago

18| model:TranslateBy(Vector3.new(0,move,0));

Here's your translation, you're moving it on the Y axis for up and down, Vector3s are set out such that (X, Y, Z) are in this order.

Depending on where your object is or how it was made left/right could be either the Z or X axis.

So try

18| model:TranslateBy(Vector3.new(0,0,move));

or

18| model:TranslateBy(Vector3.new(move,0,0));

And see if either of those work.

Ad

Answer this question