Door tween using multiple tables help

I have just learned how to create tweens and want to make a door with 2 parts that opens and closes. What i’m wondering is if theres a less messy method to creating the different positions on a table.

local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Quad)

local doors = script.Parent
local topDoor = doors.topDoor
local bottomDoor = doors.bottomDoor

local bottomOpen = {}
bottomOpen.CFrame = bottomDoor.CFrame + Vector3.new(0,-2,0)

local bottomClosed = {}
bottomClosed.CFrame = bottomDoor.CFrame
		
local topOpen = {}
topOpen.CFrame = topDoor.CFrame + Vector3.new(0,5,0)

local topClosed = {}
topClosed.CFrame = topDoor.CFrame 

Activated = false


doors.ClickDetector.MouseClick:Connect(function()
	if Activated == false then
		local topOpen = tweenService:Create(topDoor,tweenInfo,topOpen)
		local bottomOpen = tweenService:Create(bottomDoor,tweenInfo,bottomOpen)
		
		topOpen:Play()	
		bottomOpen:Play()
		topOpen.Completed:Wait()
		
		Activated = true
		
	elseif Activated == true then
		local topClosed = tweenService:Create(topDoor,tweenInfo,topClosed)
		local bottomClosed = tweenService:Create(bottomDoor,tweenInfo,bottomClosed)

		topClosed:Play()	
		bottomClosed:Play()
		topClosed.Completed:Wait()

		Activated = false
	end	
end)

I have created 4 separate tables to hold the values for open and close and i’m wondering if theirs a way for me to do this in only 1 table.

2 Likes