Advertisement
Quoteory

Untitled

Aug 4th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. -- Grid Service
  2. -- Quoteory
  3. -- August 4, 2019
  4.  
  5. --[[
  6.    
  7.     Server:
  8.        
  9.    
  10.  
  11.  
  12.     Client:
  13.        
  14.    
  15.  
  16. --]]
  17.  
  18.  
  19.  
  20.  
  21. local GridService = {Client = {}}
  22.  
  23. local Cube
  24.  
  25. function GridService:GenerateGrid(Position, Size, GridSize)
  26.    
  27.     local centerPart = Instance.new("Part")
  28.     centerPart.BrickColor = BrickColor.Red()
  29.     centerPart.Size = Vector3.new(2, 10, 2)
  30.     centerPart.Anchored = true
  31.     centerPart.Position = Position
  32.     centerPart.Parent = workspace
  33.    
  34.     local centerCFrame = centerPart.CFrame
  35.     local SizeX = Size.X
  36.     local Width = SizeX * GridSize
  37.    
  38.     for x = 1, GridSize do
  39.         for z = 1, GridSize do
  40.             local Offset = CFrame.new(-(Width/2)-SizeX/2, 0, -(Width/2)-SizeX/2)
  41.             local CF = centerCFrame * CFrame.new(SizeX * x, 0, Size.Z * z) * Offset
  42.             local cube = Cube.new(Size, CF.Position)
  43.         end
  44.     end
  45.    
  46.    
  47.     print("Width = " .. Width)
  48.    
  49. end
  50.  
  51. function GridService:Start()
  52.  
  53.     GridService:GenerateGrid(Vector3.new(0, 15, 0), Vector3.new(4, 4, 4), 12)
  54. end
  55.  
  56.  
  57. function GridService:Init()
  58.     Cube = self.Modules.Cube
  59. end
  60.  
  61.  
  62. return GridService
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement