There was a few little nicks in the script, like on lines 10 and 15 - it was attempting to get the 'y' Size axis of a Table (line 09, 'D').
This script should work - although, if you want each part of the door to go up/down synchronously, please use the second script.
Speed = 0.5
Time = 5
Running = false
for x,z in pairs(script.Parent.Parent:GetChildren()) do
if z.Name == "Button" then
z.CD.MouseClick:connect(function ()
if Running == true then return end
Running = true
for _,D in pairs(script.Parent.Parent:GetChildren()) do
if D:IsA("BasePart") then
for i=1,D.Size.y/Speed*10+1 do
D.CFrame = D.CFrame*CFrame.new(0,0.1*Speed,0)
wait()
end
end
end
wait(Time)
for _,D in pairs(script.Parent.Parent:GetChildren()) do
if D:IsA("BasePart") then
for i=1,D.Size.y/Speed*10+1 do
D.CFrame = D.CFrame*CFrame.new(0,-0.1*Speed,0)
wait()
end
end
end
Running = false
end)
end
end
Synchronous Movement:
Speed = 0.5
Time = 5
Running = false
for x,z in pairs(script.Parent.Parent:GetChildren()) do
if z.Name == "Button" then
z.CD.MouseClick:connect(function ()
if Running == true then return end
Running = true
for _,D in pairs(script.Parent.Parent:GetChildren()) do
if D:IsA("BasePart") then
coroutine.resume(coroutine.create(function()
for i=1,D.Size.y/Speed*10+1 do
D.CFrame = D.CFrame*CFrame.new(0,0.1*Speed,0)
wait()
end
end))
end
end
wait(Time)
for _,D in pairs(script.Parent.Parent:GetChildren()) do
if D:IsA("BasePart") then
coroutine.resume(coroutine.create(function()
for i=1,D.Size.y/Speed*10+1 do
D.CFrame = D.CFrame*CFrame.new(0,-0.1*Speed,0)
wait()
end
end))
end
end
Running = false
end)
end
end
Quick Tutor:
'coroutines' - basically allow you to run multiple things at once, like two while loops at the same time.
More Information link:
http://wiki.roblox.com/index.php?title=Coroutine_Tutorial
http://wiki.roblox.com/index.php?title=Coroutine
http://wiki.roblox.com/index.php?title=Beginners_Guide_to_Coroutines