goal.Transparency=1 door.PrimaryPart.Transparency=1 local function G(G,a,t)local d=Instance.new("\067\070\114\097\109\101\086\097\108\117\101")d.Value=G:GetPrimaryPartCFrame();(d:GetPropertyChangedSignal("\086\097\108\117\101")):Connect(function()G:SetPrimaryPartCFrame(d.Value)end)local T=tweenService:Create(d,t,{Value=a})T:Play()T.Completed:Connect(function()d:Destroy()end)end local function a()if canOpen then canOpen=false if open then open=false G(door,origCFrame,TweenInfo.new(downtime))else open=true G(door,goal.CFrame,TweenInfo.new(uptime))end wait(waitTime+uptime)canOpen=true end end clickDetector.MouseButton1Click:connect(a)


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)
