Advertisement
QuantumWarpCode

Roblox Part Functions V3

Jul 22nd, 2014
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.38 KB | None | 0 0
  1. --The bottom has explanations about how to use this.
  2.  
  3. function createPart(name1,x1,y1,z1,parent1,xs,ys,zs,type)
  4.     --Sets the properties of part.
  5.     part = Instance.new(type,parent1)
  6.     part.Name = name1
  7.     part.FormFactor = "Custom"
  8.     part.Size = Vector3.new(xs,ys,zs)
  9.     part.Position = Vector3.new(x1,y1,z1)
  10.     part.Anchored = true
  11.     part.BottomSurface = 10
  12.     part.TopSurface = 10
  13.     part.RightSurface = 10
  14.     part.LeftSurface = 10
  15.     part.FrontSurface = 10
  16.     part.BackSurface = 10
  17. end
  18.  
  19. function adjustParts(x2,y2,z2,parent2)
  20.     --Gets the children.
  21.     local c = model2:GetChildren()
  22.     for index, child in pairs(c) do
  23.         --Adjusts by addition.
  24.         child.Position = child.Position + Vector3.new(x2,y2,z2)
  25.     end
  26. end
  27.  
  28. function combineModelsN(name,base)
  29.     local c = base:GetChildren()
  30.     NewModel = Instance.new("Model",game.Workspace)
  31.     for index, child in pairs(c) do
  32.         if child.className == "Model" then
  33.             local d = child:GetChildren()
  34.             for index, children in pairs(d) do
  35.                 children.Parent = NewModel
  36.             end
  37.             child:remove()
  38.         end
  39.     end
  40. end
  41.  
  42. function combineModelsT(m1,m2,loc)
  43.     NewModel = Instance.new("Model",loc)
  44.     local c = m1:GetChildren()
  45.     for index, children in pairs(c) do
  46.         children.Parent = NewModel
  47.     end
  48.     m1:remove()
  49.     local c = m2:GetChildren()
  50.     for index, children in pairs(c) do
  51.         children.Parent = NewModel
  52.     end
  53.     m2:remove()
  54. end
  55.  
  56. function setColorM(model,color)
  57.     local c = model:GetChildren()
  58.     for index, child in pairs(c) do
  59.         child.BrickColor = color
  60.     end
  61. end
  62.  
  63. function cloneAdjust(part,iterations,dx,dy,dz,parent)
  64.     parts = 0
  65.     while parts < iterations do
  66.         parts = parts + 1
  67.         partc = part:clone()
  68.         partc.Position = partc.Position + Vector3.new(dx*(parts),dy*(parts),dz*(parts))
  69.         partc.Parent = parent
  70.     end
  71. end
  72.  
  73. --Call these as a normal functions except with _G. at the beginning
  74. --Example
  75. --_G.createPart(examplevalues)
  76.  
  77. --Creates a part
  78. _G.createPart = createPart
  79. --Adjusts all parts in a model
  80. _G.adjustParts = adjustParts
  81. --Combines all models of the same name in the same location
  82. _G.combineModelsN = combineModelsN
  83. --Combines models by two values
  84. _G.combineModelsT = combineModelsT
  85. --Sets the color of all blocks in a model
  86. _G.setColorM = setColorM
  87. --Clones a part and adjusts them by the iteration multiplied by values you give
  88. _G.cloneAdjust = cloneAdjust
  89.  
  90. _G.FunctionsStored = true --Make scripts wait for this to use functions
  91.  
  92. script:Destroy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement