Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Model Vector Open and Close gate?

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

✓ Accepted answer

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.

1 comment

0

So where would you put this in the Model? Would you put it in the button or the whole model itself?

This discussion is preserved as it was. New answers, comments, and votes are closed.