How would I be able to tween this elevator down?

Maybe try Maybe89’s code he wrote a reply to your issue.

I did I used Model:PivotTo()

@coolgamer294855 ?

Can you maybe give me the current code you are using? @TeamDreams123

Sure!

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 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)
	ELEVATOR:PivotTo(-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)
	ELEVATOR:PivotTo(2.15, -25.65, -48.95)
	wait(3)
	tween4:Play() -- Open second door (SIDE)
	wait(1)
	tween3:Play() -- Open first door (TOP)
end)
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 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)
	ELEVATOR:PivotTo(-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)
	ELEVATOR:PivotTo(2.15, -25.65, -48.95)
	wait(3)
	tween4:Play() -- Open second door (SIDE)
	wait(1)
	tween3:Play() -- Open first door (TOP)
end)

The code had a few errors, the first being that it was missing a closing curly brace at the end. The second error was that the “wait” function was spelled incorrectly, and the third error was that the “tween1:Play()” line was missing a semicolon.

I didnt test this I am not sure if this works.
I also just flew over the code.

1 Like

If you want to tween it then use 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 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)

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

script.Parent.ProximityPrompt.Triggered:Connect(function()
	tween1:Play() -- Close first door (TOP)
	wait(3)
	tween2:Play() -- Close second door (SIDE)
	wait(3)
	tweenModel(ELEVATOR, CFrame.new(-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)
	tweenModel(ELEVATOR, CFrame.new(2.15, -25.65, -48.95))
	wait(3)
	tween4:Play() -- Open second door (SIDE)
	wait(1)
	tween3:Play() -- Open first door (TOP)
end)
1 Like

@TeamDreams123 Maybe this answer can help you.

1 Like

It works but then it teleports me downwards, sending me to my demise.

@coolgamer294855, @Almosta_89 : I will provide a video, please give me a second!

1 Like

Alright, I will wait until you provide the video.

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 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)

-- 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)
		ELEVATOR: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

script.Parent.ProximityPrompt.Triggered:Connect(function()
	tween1:Play() -- Close first door (TOP)
	wait(3)
	tween2:Play() -- Close second door (SIDE)
	wait(5)
	tweenModel(ELEVATOR, CFrame.new(-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)
	wait(5)
	tweenModel(ELEVATOR, CFrame.new(2.15, -25.65, -48.95))
	wait(3)
	tween4:Play() -- Open second door (SIDE)
	wait(1)
	tween3:Play() -- Open first door (TOP)
end)
Video (i had obby creator playing in the background lol)

@coolgamer294855 @Almosta_89

The issue on the previous script is that you are not moving with the elevator when it moves.

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 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)

-- 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)
		ELEVATOR: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

script.Parent.ProximityPrompt.Triggered:Connect(function()
	tween1:Play() -- Close first door (TOP)
	wait(3)
	tween2:Play() -- Close second door (SIDE)
	wait(5)
	tweenModel(ELEVATOR, CFrame.new(-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)
	wait(5)
	tweenModel(ELEVATOR, CFrame.new(2.15, -25.65, -48.95))
	wait(3)
	tween4:Play() -- Open second door (SIDE)
	wait(1)
	tween3:Play() -- Open first door (TOP)
end)

I think this may work that you are not being thrown out anymore.

What do you mean

I’m so confused, It literally is broken

That was to basically avoid admins flagging my post for just throwing code in.

Ok now it is just fully broken it is now floating around the place :interrobang:

Oh well sadly I cannot help with this issue anymore, I tried my best but nothing seems to work, I maybe can grab code from one of my games, if you want a code obviously. But that won’t work because it isn’t a part moving inside a part, it is basically just a sliding door. So giving you the code won’t help with anything.

1 Like

I kinda give up too. I will try and work it out myself…

Alright, goodluck. I hope the best of the best for you.

1 Like

Hello, I managed to fix it! keep a note that this expects a model with a primary part!

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 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)

-- 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 a model directly
	local cframeValue = Instance.new("CFrameValue")
	
	-- set the orignal value of the model
	cframeValue.Value = model.PrimaryPart.CFrame
	-- 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
	tween.Completed:Wait() -- wait for the tween to end (can cause some bugs)
end

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

Hope this helps!

No need to give up. The solution is pretty simple, instead of using position, use CFrames.

First, set the primary part to whatever part you want, then weld every other part to the primary part, then unanchor the welded parts, now all you have to do is tween the anchored primary part using cframes.

local TweenService = game:GetService("TweenService")
local elevator = game.Workspace.Elevator

local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local goal = -- some cframe.

local tween = TweenService:Create(elevator.PrimaryPart, info, {CFrame = goal})

tween:Play()

Here’s some example code showing how easy it is once you set everything up.

2 Likes

Thank you for coming back, I will try this out! :wink: