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

Model Vector Open and Close gate?

Asked by
steev 0
10 years ago

When the player clicks on a button the gate moves up a few meters off of the ground. When the player clicks the button again the gate moves back into it's starting position.

I am trying to do this with a model of a castle gate which means there is few bricks in the model.

1 answer

Log in to vote
0
Answered by 10 years ago

Use the :TranslateBy(); method, for example:

local model = game.Workspace["MODELNAME"]; -- The model you want to move up
local part = model["MAINPART"]; -- The main part of the model (will be used as the center)
local increment = 1 --The amount you want it to go up by each time
local max = 10 --The studs you want to go up by

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

Button.MouseClick:connect(onClick());

This shifts the model upwards/downward depending on the closed boolean.

0
So where would you put this in the Model? Would you put it in the button or the whole model itself? steev 0 — 10y
Ad

Answer this question