Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size = 1 --Change this to the size of each part.
- function createPart(name,x1,y1,z1,parent1)
- --Sets the properties of part.
- part = Instance.new("Part",parent1)
- part.Name = name
- part.FormFactor = "Custom"
- part.Size = Vector3.new(size,size,size)
- part.Position = Vector3.new(x1,y1,z1)
- part.Anchored = true
- part.BottomSurface = 10
- part.TopSurface = 10
- part.RightSurface = 10
- part.LeftSurface = 10
- part.FrontSurface = 10
- part.BackSurface = 10
- end
- function spongeClone(model,iteration)
- adjustment = 3^(iteration-1)*size
- print(adjustment)
- --Then a bunch of lines for the pattern.
- newModel1 = model:clone()
- newModel1.Parent = game.Workspace
- adjustParts(newModel1,adjustment,0,0)
- newModel2 = model:clone()
- newModel2.Parent = game.Workspace
- adjustParts(newModel2,adjustment*2,0,0)
- newModel3 = model:clone()
- newModel3.Parent = game.Workspace
- adjustParts(newModel3,0,adjustment,0)
- newModel4 = model:clone()
- newModel4.Parent = game.Workspace
- adjustParts(newModel4,0,adjustment*2,0)
- newModel5 = model:clone()
- newModel5.Parent = game.Workspace
- adjustParts(newModel5,0,0,-1*adjustment)
- newModel6 = model:clone()
- newModel6.Parent = game.Workspace
- adjustParts(newModel6,0,0,-1*(adjustment*2))
- newModel7 = model:clone()
- newModel7.Parent = game.Workspace
- adjustParts(newModel7,0,adjustment*2,-1*adjustment)
- newModel8 = model:clone()
- newModel8.Parent = game.Workspace
- adjustParts(newModel8,0,adjustment*2,-1*(adjustment*2))
- newModel9 = model:clone()
- newModel9.Parent = game.Workspace
- adjustParts(newModel9,0,adjustment,-1*(adjustment*2))
- newModel10 = model:clone()
- newModel10.Parent = game.Workspace
- adjustParts(newModel10,adjustment,adjustment*2,0)
- newModel12 = model:clone()
- newModel12.Parent = game.Workspace
- adjustParts(newModel12,adjustment*2,adjustment*2,0)
- newModel13 = model:clone()
- newModel13.Parent = game.Workspace
- adjustParts(newModel13,adjustment*2,adjustment,0)
- newModel14 = model:clone()
- newModel14.Parent = game.Workspace
- adjustParts(newModel14,adjustment*2,0,-1*adjustment)
- newModel15 = model:clone()
- newModel15.Parent = game.Workspace
- adjustParts(newModel15,adjustment*2,0,-1*(adjustment*2))
- newModel16 = model:clone()
- newModel16.Parent = game.Workspace
- adjustParts(newModel16,adjustment*2,adjustment*2,-1*adjustment)
- newModel17 = model:clone()
- newModel17.Parent = game.Workspace
- adjustParts(newModel17,adjustment*2,adjustment*2,-1*(adjustment*2))
- newModel18 = model:clone()
- newModel18.Parent = game.Workspace
- adjustParts(newModel18,adjustment*2,adjustment,-1*(adjustment*2))
- newModel19 = model:clone()
- newModel19.Parent = game.Workspace
- adjustParts(newModel19,adjustment,0,-1*(adjustment*2))
- newModel20 = model:clone()
- newModel20.Parent = game.Workspace
- adjustParts(newModel20,adjustment,adjustment*2,-1*(adjustment*2))
- --Combine them all to the same model.
- combineModels(Model)
- passingModel = game.Workspace.Model
- --Set the generations to 1 or 2 if you dont want lag. On 3 it will take a minute to create and higher numbers cause lag and may crash the game.
- if iteration < 3 then --This number is how many generations.
- spongeClone(passingModel,iteration + 1)
- end
- end
- function adjustParts(model2,x2,y2,z2)
- --Gets the children.
- local c = model2:GetChildren()
- for index, child in pairs(c) do
- --Adjusts by addition.
- child.Position = child.Position + Vector3.new(x2,y2,z2)
- end
- end
- function combineModels(name)
- local c = game.Workspace:GetChildren()
- NewModel = Instance.new("Model",game.Workspace)
- for index, child in pairs(c) do
- if child.className == "Model" then
- local d = child:GetChildren()
- for index, children in pairs(d) do
- children.Parent = NewModel
- end
- child:remove()
- end
- end
- end
- BaseModel = Instance.new("Model",game.Workspace)
- createPart("Block",0,0,0,BaseModel)
- spongeClone(BaseModel,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement