Hello guys,im new on scripting.I Tried to write a sliding door script that closes after 40 seconds.It worked without closing script at first.

local Part = Workspace.otobusgarajkapisi --here is the door
local newPos = Part.Position + Vector3.new(0,20,0)
local Time = 5
local Increment = 0.2
local Debounce = false
 
local Diff = newPos - Part.Position 
local Mag = Diff.magnitude 
local Direction = CFrame.new(Part.Position, newPos).lookVector
function MovePart() 
	if Debounce then return end 
	Debounce = true 
	for n = 0, Mag, Increment do
		Part.CFrame = Part.CFrame + (Direction * Increment)
		wait( (Time/Mag) * Increment )
	end
	Debounce = false
end
Workspace.otobusgarajbutonu.ClickDetector.MouseClick:connect(MovePart)--here is button
--there is no "closing" script

Then i tried to add closing script (door closes after 40 seconds)

local Part = Workspace.otobusgarajkapisi --here is the door
local newPos = Part.Position + Vector3.new(0,15,0)
local Time = 5
local Increment = 0.2
local Debounce = false
 
local Diff = newPos - Part.Position 
local Mag = Diff.magnitude 
local Direction = CFrame.new(Part.Position, newPos).lookVector
function MovePart() 
	if Debounce then return end 
	Debounce = true 
	for n = 0, Mag, Increment do
		Part.CFrame = Part.CFrame + (Direction * Increment)
		wait( (Time/Mag) * Increment )
	end
	Debounce = false --Closing script is below (starting with wait)
	wait (40)
	local Part = Workspace.otobusgarajkapisi
	local newPos = Part.Position + Vector3.new (0,-15,0)
	local Time = 5
	local Increment = 0.2
	local Debounce = false
end

	
end
Workspace.otobusgarajbutonu.ClickDetector.MouseClick:connect(MovePart)--here is button
--there is "closing" script added on

Now door never opens.(I Click to button that triggers the event.still nothing) Is there something i writed wrong ? Please help. Thanks.