Untitled

mail@pastecode.io avatar
unknown
lua
a year ago
1.9 kB
1
Indexable
Never
```lua
function Chunk.new(biome)
   for x = 0,size do
      for z = 0,size do
         local part = Instance.new("Part")
         part.Parent = container
         part.Anchored = true
         part.Size = Vector3.new(blockSize,blockSize,blockSize)
         part.Color = Color3.fromRGB(71, 255, 38)
            
         local height = getHeight(x,z)

         part.Position = Vector3.new(x*blockSize,math.round(height*amplitude)*blockSize ,z*blockSize)
            
         local dirtBlock
            
         for i = 1, VerticalRowSizeDirt do
             local dirt = Instance.new("Part")
             dirt.Parent = container
             dirt.Anchored = true
             dirt.Size = Vector3.new(blockSize,blockSize,blockSize)
             dirt.Color = Color3.fromRGB(138, 86, 14)
             
             dirt.Position = part.Position - Vector3.new(0,blockSize,0)*i

             if i == VerticalRowSizeDirt then
                dirtBlock = dirt
             end 
         end
   
         for v = 1, VerticleRowSizeStone do
            local SpawnIron = math.random(1,20)
                
            if SpawnIron == 20 then
               local iron = Instance.new("Part")
               iron.Parent = container
               iron.Anchored = true
               iron.Size = Vector3.new(blockSize,blockSize,blockSize)
               iron.Color = Color3.fromRGB(218, 163, 67)
               iron.Position = dirtBlock.Position - Vector3.new(0,blockSize,0)*v
            else
               local stone = Instance.new("Part")
               stone.Parent = container
               stone.Anchored = true
               stone.Size = Vector3.new(blockSize,blockSize,blockSize)
               stone.Color = Color3.fromRGB(76, 76, 76)

               stone.Position = dirtBlock.Position - Vector3.new(0,blockSize,0)*v
            end
         end
      end
      game:GetService("RunService").Heartbeat:Wait()
   end
end
```