How to reduce lag from a number of parts

local Workspace = game:GetService("Workspace")

local function Setdirtbrick(Size : Vector3, Position : Vector3)
	local Brick = Instance.new("Part", Workspace.Bricks.Ground)
	Brick.Anchored = true
	Brick.Size = Size
	Brick.Position = Position
end

local function SetbrickLine(StartPoint : Vector3) -- moves positive X value
	local Number = math.abs(StartPoint.X) * 4
	for num = 0, Number do
		Setdirtbrick(Vector3.new(0.5,0.5,0.5), StartPoint + Vector3.new(num / 2, 0, 0))
	end 
end

local function Setbrick2d(Size, Height)
	local StartPoint = Vector3.new(-Size/2, Height, -Size/2)
	for num = 0, Size * 2 do
		SetbrickLine(StartPoint + Vector3.new(0,0, num / 2))
	end
end

Setbrick2d(200, 1)

Heres my code

You use greedy meshing.

1 Like