Can someone help me find the problem in the last line? The last line is the only one thats a problem... FYI this is a garage door and I have a button that I want to open the door.
Thanks!
Script:
local Door = script.Parent.DoorParts:GetChildren()
local Open = false
local Closed = true
local Locked = true
local Door1 = script.Parent.DoorParts.Door1:GetChildren()
local Door2 = script.Parent.DoorParts.Door2:GetChildren()
local Door3 = script.Parent.DoorParts.Door3:GetChildren()
function DoOpen()
if Closed and not Open then
Open = true
for i=1, 132 do
for D1=1, #Door1 do
if script.Parent.DoorParts.Door1:FindFirstChild("Pos").Value > i then
if Door1[D1]:IsA("Part") then
Door1[D1].CFrame = Door1[D1].CFrame * CFrame.new(0, 0.1, 0)
end
end
end
for D2=1, #Door2 do
if script.Parent.DoorParts.Door2:FindFirstChild("Pos").Value > i then
if Door2[D2]:IsA("Part") then
Door2[D2].CFrame = Door2[D2].CFrame * CFrame.new(0, 0.1, 0)
end
end
end
for D3=1, #Door3 do
if script.Parent.DoorParts.Door3:FindFirstChild("Pos").Value > i then
if Door3[D3]:IsA("Part") then
Door3[D3].CFrame = Door3[D3].CFrame * CFrame.new(0, 0.1, 0)
end
end
end
wait()
end
Open = true
Closed = false
game.Workspace.TVVV1234.Light.BrickColor = BrickColor.new("Bright green")
end
end
function DoClose()
if Open and not Closed then
Closed = true
for i=1, 132 do
for D3=1, #Door3 do
if script.Parent.DoorParts.Door3:FindFirstChild("Pos").Value > i then
if Door3[D3]:IsA("Part") then
Door3[D3].CFrame = Door3[D3].CFrame * CFrame.new(0, -0.1, 0)
end
end
end
for D2=1, #Door2 do
if script.Parent.DoorParts.Door2:FindFirstChild("Pos").Value > i then
if Door2[D2]:IsA("Part") then
Door2[D2].CFrame = Door2[D2].CFrame * CFrame.new(0, -0.1, 0)
end
end
end
for D1=1, #Door1 do
if script.Parent.DoorParts.Door1:FindFirstChild("Pos").Value > i then
if Door1[D1]:IsA("Part") then
Door1[D1].CFrame = Door1[D1].CFrame * CFrame.new(0, -0.1, 0)
end
end
end
wait()
end
Open = false
Closed = true
game.Workspace.TVVV1234.Light.BrickColor = BrickColor.new("Really red")
end
end
script.Parent.RFID.Changed:connect(function()
if script.Parent.RFID.Value == true then
if Closed then
DoOpen()
end
if Open then
DoClose()
end
script.Parent.RFID.Value = false
end
end)
script.Parent.RFIDUnlock.Changed:connect(function()
Locked = script.Parent.RFIDUnlock.Value
end)
script.Parent.ButtonOpen.ClickDetector.MouseClick:connect(function() if not Locked then DoOpen() end end)
script.Parent.ButtonClose.ClickDetector.MouseClick:connect(function() if not Locked then DoClose() end end)
script.Parent.Parent.Bump.Touched:connect(function() DoOpen() wait (5) DoClose() end)
game.StarterGui.Door.FirstFloor.Exit.onClicked:connect(function() DoOpen() wait (5) DoClose() end)
a penny saved is a penny earned but the government will take it anyways. |