I'm creating an elevator and I scripted a button to where when you click it, the elevator doors open and then close after 4 seconds. But for some reason, the output is telling me there is an error on line 22 (I made a comment on where that line is.) How can I fix this?

local TweenService = game:GetService("TweenService")
local model = workspace.Elevator
local button = script.Parent
local main = model.Main
local door1 = model.Floor1Door1
local door2 = model.Floor1Door2
local tweeningInfo = TweenInfo.new(
	
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
	
)

local door1open = model.Floor1Door1Open.Position and model.Floor1Door1Open.Orientation
local door2open = model.Floor1Door2Open.Position and model.Floor1Door2Open.Orientation
local door1close = model.Floor1Door1Close.Position and model.Floor1Door1Close.Orientation
local door2close = model.Floor1Door2Close.Position and model.Floor1Door2Close.Orientation
local tween1Open = TweenService:Create(door1,tweeningInfo,door1open) -- Line 22. For some reason, this line has an error but I don't see what it is. I triple-checked everything and everything seemed good.
local tween1Close = TweenService:Create(door1,tweeningInfo,door1close)
local tween2Open = TweenService:Create(door2,tweeningInfo,door2open)
local tween2Close = TweenService:Create(door2,tweeningInfo,door2close) 

script.Parent.MouseClick:Connect(function()
	tween1Open:Play()
	tween2Open:Play()
	wait(4)
	tween1Close:Play()
	tween2Close:Play()
end)

1 comment

0

In your door1open variable, do {position, orientation} instead. And on line 22 where you use the variable, do door1open[1], door1open[2] instead of door1open