How would I be able to tween this elevator down?

Hey there,

How would I be able to make this elevator tween down? This is what I want it to look like: (sorry its a bit unclear)

And this is my script:

local TweenService = game:GetService("TweenService")

local TOP_DOOR = script.Parent.Parent.Parent.Doors.TOP_DOOR
local SIDE_DOOR	 = script.Parent.Parent.Parent.Doors.SIDE_DOOR
local ELEVATOR = script.Parent.Parent.Parent

local goal = {}
goal.Position = Vector3.new(5.35, -29.75, -46.05)

local goaltwo = {}
goaltwo.Position = Vector3.new(5.35, -21.75, -46.05)

local goalthree = {}
goalthree.Position = Vector3.new(-1.15, -29.45, -46.05)

local elevatordowngoal = {}
elevatordowngoal.Position = Vector3.new(-1.15, -29.45, -46.05)

local elevatorupgoal = {}
elevatorupgoal.Position = Vector3.new(2.15, -25.65, -48.95)

local tweenInfo = TweenInfo.new(5)

-- Close
local tween1 = TweenService:Create(TOP_DOOR, tweenInfo, goal)
local tween2 = TweenService:Create(SIDE_DOOR, tweenInfo, goal)

-- Open
local tween3 = TweenService:Create(TOP_DOOR, tweenInfo, goaltwo)
local tween4 = TweenService:Create(SIDE_DOOR, tweenInfo, goalthree)

-- Elevator Movement
local elevatortweendown = TweenService:Create(ELEVATOR, tweenInfo, elevatordowngoal) -- DOWN
local elevatortweenup = TweenService:Create(ELEVATOR, tweenInfo, elevatorupgoal) -- UP

script.Parent.ProximityPrompt.Triggered:Connect(function()
	tween1:Play() -- Close first door (TOP)
	wait(3)
	tween2:Play() -- Close second door (SIDE)
	wait(3)
	elevatortweendown:Play() -- Move down
	wait(1)
	tween4:Play() -- Open first door (TOP)
	wait(1)
	tween3:Play() -- Open second door (SIDE)
	wait(6)
	tween1:Play()  -- Close first door (TOP)
	wait(3)
	tween2:Play() -- Close second door (SIDE)
	elevatortweenup:Play() -- Move up
	wait(3)
	tween4:Play() -- Open second door (SIDE)
	wait(1)
	tween3:Play() -- Open first door (TOP)
end)

:heart: Help is truly appreciated! :heart:

:heart: Help is truly appreciated!

I would really love if someone helped me!

can you explain what you’re having issues with, is it that you can’t tween the entire model or getting the right position. Can you be a bit more specific about what your issue is

You can use the MoveTo() function on a Model to move it up and down.

local goal = {}
goal.Position = Vector3.new(5.35, -29.75, -46.05)

local goaltwo = {}
goaltwo.Position = Vector3.new(5.35, -21.75, -46.05)

local goalthree = {}
goalthree.Position = Vector3.new(-1.15, -29.45, -46.05)

local elevatordowngoal = {}
elevatordowngoal.Position = Vector3.new(-1.15, -29.45, -46.05)

local elevatorupgoal = {}
elevatorupgoal.Position = Vector3.new(2.15, -25.65, -48.95)

local tweenInfo = TweenInfo.new(5)

-- Close
local tween1 = TweenService:Create(TOP_DOOR, tweenInfo, goal)
local tween2 = TweenService:Create(SIDE_DOOR, tweenInfo, goal)

-- Open
local tween3 = TweenService:Create(TOP_DOOR, tweenInfo, goaltwo)
local tween4 = TweenService:Create(SIDE_DOOR, tweenInfo, goalthree)

-- Elevator Movement
local elevatortweendown = TweenService:Create(ELEVATOR, tweenInfo, elevatordowngoal) -- DOWN
local elevatortweenup = TweenService:Create(ELEVATOR, tweenInfo, elevatorupgoal) -- UP

script.Parent.ProximityPrompt.Triggered:Connect(function()
    tween1:Play() -- Close first door (TOP)
    wait(3)
    tween2:Play() -- Close second door (SIDE)
    wait(3)
    elevatortweendown:Play() -- Move down
    wait(1)
    tween4:Play() -- Open first door (TOP)
    wait(1)
    tween3:Play() -- Open second door (SIDE)
    wait(6)
    tween1:Play()  -- Close first door (TOP)
    wait(3)
    tween2:Play() -- Close second door (SIDE)
    elevatortweenup:Play() -- Move up
    wait(3)
    tween4:Play() -- Open second door (SIDE)
    wait(1)
    tween3:Play() -- Open first door (TOP)
end)

It won’t work. No errors either.

Do you have any examples I could use?

I believe that is the example also I forgot to add the

local TweenService = game:GetService("TweenService")

local TOP_DOOR = script.Parent.Parent.Parent.Doors.TOP_DOOR
local SIDE_DOOR	 = script.Parent.Parent.Parent.Doors.SIDE_DOOR
local ELEVATOR = script.Parent.Parent.Parent

To the script above

Okay, how would I be able to use the MoveTo() function you said about?

@coolgamer294855 ?

The moveto() function takes two arguments: the x-coordinate and the y-coordinate of the destination. For example, to move the elevator to the point (4,2), you would use the following code:

moveto(4,2)

So how would I be able to make it into a script??

local TweenService = game:GetService("TweenService")

local TOP_DOOR = script.Parent.Parent.Parent.Doors.TOP_DOOR
local SIDE_DOOR	 = script.Parent.Parent.Parent.Doors.SIDE_DOOR
local ELEVATOR = script.Parent.Parent.Parent

local goal = {}
goal.Position = Vector3.new(5.35, -29.75, -46.05)

local goaltwo = {}
goaltwo.Position = Vector3.new(5.35, -21.75, -46.05)

local goalthree = {}
goalthree.Position = Vector3.new(-1.15, -29.45, -46.05)

local elevatordowngoal = {}
elevatordowngoal.Position = MoveTo(4,2) -- huh?

local elevatorupgoal = {}
elevatorupgoal.Position = MoveTo(4,2) -- huh?

local tweenInfo = TweenInfo.new(5)

-- Close
local tween1 = TweenService:Create(TOP_DOOR, tweenInfo, goal)
local tween2 = TweenService:Create(SIDE_DOOR, tweenInfo, goal)

-- Open
local tween3 = TweenService:Create(TOP_DOOR, tweenInfo, goaltwo)
local tween4 = TweenService:Create(SIDE_DOOR, tweenInfo, goalthree)

-- Elevator Movement
local elevatortweendown = TweenService:Create(ELEVATOR, tweenInfo, elevatordowngoal) -- DOWN
local elevatortweenup = TweenService:Create(ELEVATOR, tweenInfo, elevatorupgoal) -- UP

script.Parent.ProximityPrompt.Triggered:Connect(function()
	tween1:Play() -- Close first door (TOP)
	wait(3)
	tween2:Play() -- Close second door (SIDE)
	wait(3)
	elevatortweendown:Play() -- Move down
	wait(1)
	tween4:Play() -- Open first door (TOP)
	wait(1)
	tween3:Play() -- Open second door (SIDE)
	wait(6)
	tween1:Play()  -- Close first door (TOP)
	wait(3)
	tween2:Play() -- Close second door (SIDE)
	elevatortweenup:Play() -- Move up
	wait(3)
	tween4:Play() -- Open second door (SIDE)
	wait(1)
	tween3:Play() -- Open first door (TOP)
end)

@coolgamer294855 ?

I believe you remove the tween3:Play() and replace it with the moveto() function. And in the moveto() you would place the cordinates the elevator would move to.

You mean the elevatormovedown:Play() & elevatormoveup:Play()?

Yes, I mean that sorry my english kinda bad today.
EDIT: I forgot that the tweenservice is meant for the doors, sorry.
@TeamDreams123

So how would I be able to do that?
Like this:

local TweenService = game:GetService("TweenService")

local TOP_DOOR = script.Parent.Parent.Parent.Doors.TOP_DOOR
local SIDE_DOOR	 = script.Parent.Parent.Parent.Doors.SIDE_DOOR
local ELEVATOR = script.Parent.Parent.Parent

local goal = {}
goal.Position = Vector3.new(5.35, -29.75, -46.05)

local goaltwo = {}
goaltwo.Position = Vector3.new(5.35, -21.75, -46.05)

local goalthree = {}
goalthree.Position = Vector3.new(-1.15, -29.45, -46.05)

local elevatordowngoal = {}
elevatordowngoal.Position = Vector3.new(-1.15, -29.45, -46.05)

local elevatorupgoal = {}
elevatorupgoal.Position = Vector3.new(2.15, -25.65, -48.95)

local tweenInfo = TweenInfo.new(5)

-- Close
local tween1 = TweenService:Create(TOP_DOOR, tweenInfo, goal)
local tween2 = TweenService:Create(SIDE_DOOR, tweenInfo, goal)

-- Open
local tween3 = TweenService:Create(TOP_DOOR, tweenInfo, goaltwo)
local tween4 = TweenService:Create(SIDE_DOOR, tweenInfo, goalthree)

script.Parent.ProximityPrompt.Triggered:Connect(function()
	tween1:Play() -- Close first door (TOP)
	wait(3)
	tween2:Play() -- Close second door (SIDE)
	wait(3)
	MoveTo(-1.15, -29.45, -46.05)
	wait(1)
	tween4:Play() -- Open first door (TOP)
	wait(1)
	tween3:Play() -- Open second door (SIDE)
	wait(6)
	tween1:Play()  -- Close first door (TOP)
	wait(3)
	tween2:Play() -- Close second door (SIDE)
	MoveTo(2.15, -25.65, -48.95)
	wait(3)
	tween4:Play() -- Open second door (SIDE)
	wait(1)
	tween3:Play() -- Open first door (TOP)
end)

Both of the MoveTo() functions are underlined in red and say: Unknown Global MoveTo()

You’re looking to use Model:PivotTo()

-- this allows models to be tweened using a cframe value
local function tweenModel(model: Model, cframe: CFrame)
	-- this is a value that can be tweened it's impossible to tween model directly
	local cframeValue = Instance.new("CFrameValue")
	
	-- this is the tween that move the cframevalue to the goal
	local tween = TweenService:Create(cframeValue, tweenInfo, {
		Value = cframe,
	})
	-- this event update every time the cframevalue update which means we get a tween-like look
	local conn; conn = cframeValue.Changed:Connect(function(value)
		model:PivotTo(value) -- we want to move to the position the cframevalue is at
	end)
	-- once finished we don't want to use it again so we have to cleanup
	tween.Completed:Once(function()
		conn:Disconnect()
		cframeValue:Destroy()
	end)
	
	tween:Play() -- play the cframevalue tween which will start updating the model
end
1 Like

So I just checked again and I believe that the moveto() function is actually updated so you need to use Model:PivotTo() I believe that this is correct, I don’t exactly know.
@TeamDreams123

Oki! Thank you, I will try that shortly! :slight_smile:

Aight thanks for updating it, I didn’t know the moveto() was outdated.

Oh yeah, make sure to make set the answer to Maybe89’s answer. He got it before me.

It won’t work. The first 2 tweens work (close first and second door) but then it just gets you stuck. In the output bar, it says:

Stack Begin  -  Studio
Script 'Workspace.Map.Underground Space.Elevator.keypad.START.Script', Line 31  -  Studio
Stack End  -  Studio

@coolgamer294855 ?