Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Unscaffoldise(scaffolding)
- local parts = scaffolding:GetChildren()
- table.sort(parts, function (a, b) if a.Position.Y > b.Position.Y then return true else return false end end)
- local decks = {}
- local poles = {}
- for i = 1, #parts do
- if parts[i].Name == "Pole" then
- table.insert(poles, parts[i])
- elseif parts[i].Name == "Deck" then
- table.insert(decks, parts[i])
- end
- end
- local Poles_per_level = 0
- local height = 0
- for i = 1, #poles do
- if height == 0 then
- height = math.floor(poles[i].Position.Y)
- Poles_per_level = Poles_per_level + 1
- elseif height ~= math.floor(poles[i].Position.Y) then
- break
- else
- Poles_per_level = Poles_per_level + 1
- end
- end
- local levels = (#poles / Poles_per_level) - 1
- local OldCFrame = decks[1].CFrame
- decks[1].Size = decks[1].Size + Vector3.new(0.01, 0.01, 0.01)
- decks[1].CFrame = OldCFrame
- for i = 1, Poles_per_level do
- delay(0, function ()
- for y = 6, 0, -2 do
- wait(0.2)
- if y == 0 then
- poles[i]:Destroy()
- else
- local NewCFrame = poles[i].CFrame + Vector3.new(0, -1, 0)
- poles[i].Size = Vector3.new(2, y, 2)
- poles[i].CFrame = NewCFrame
- end
- end
- end)
- end
- wait(0.2 * 4)
- local polesdeleted = Poles_per_level
- for level = 1, levels do
- for i = polesdeleted + 1, polesdeleted + Poles_per_level do
- delay(0, function ()
- for y = 6, 0, -2 do
- wait(0.2)
- if y == 0 then
- poles[i]:Destroy()
- else
- local NewCFrame = poles[i].CFrame + Vector3.new(0, -1, 0) --attempt to index upvalue 'poles' (a nil value)
- poles[i].Size = Vector3.new(2, y, 2)
- poles[i].CFrame = NewCFrame
- end
- end
- end)
- end
- wait(0.2 * 4)
- polesdeleted = polesdeleted + Poles_per_level
- if level ~= levels then
- TweenTo(decks[1], decks[2].Position, 0.5, "Bounce") --attempt to index field '?' (a nil value)
- decks[2]:Destroy()
- table.remove(decks, 2)
- else
- TweenTo(decks[1], decks[1].Position + Vector3.new(0, -8, 0), 0.5, "Bounce")
- end
- end
- decks[1]:Destroy()
- end
- --This bit calls the function
- scaffs = {}
- for n, a in pairs(game.Workspace.Model:GetChildren()) do
- delay(0, function ()
- print(n)
- a.Parent = Instance.new("Model", a.Parent)
- scaffs[n] = Scaffoldise(a.Parent, a.Size, Instance.new("Model", game.Workspace))
- Build(a.Parent)
- Unscaffoldise(scaffs[n]) --everything works except this
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement