--yep


goal.Transparency = 1
door.PrimaryPart.Transparency = 1

local function tweenModel(model, CF, info)
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Value = model:GetPrimaryPartCFrame()

	CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
		model:SetPrimaryPartCFrame(CFrameValue.Value)
	end)
	
	local tween = tweenService:Create(CFrameValue, info, {Value = CF})
	tween:Play()
	
	tween.Completed:Connect(function()
		CFrameValue:Destroy()
	end)
end

local function onClicked()
	if canOpen then
		canOpen = false
		
		if open then
			open = false
			
			tweenModel(door, origCFrame, TweenInfo.new(downtime))
		else
			open = true
			
			tweenModel(door, goal.CFrame, TweenInfo.new(uptime))
		end
		
		wait(waitTime + uptime)
		canOpen = true
	end
end

clickDetector.MouseButton1Click:connect(onClicked)
