My goal is to generate a large amount of parts in this specific area:
The parts will come in two different sizes (2x2x2,3x3x3) and they should not be overlapping with eachother. The problem is that I have no idea how I would go about this.
This has a little bit of math, but it’s easy if you do it correctly.
Try this:
local bounds = workspace.Part --Redirect this to your part
for i = 1,50 do
local newPart = Instance.new("Part", workspace)
newPart.Name = tostring(i)
newPart.Anchored = true
newPart.Size = Vector3.new(1,1,1)
newPart.Position = Vector3.new(math.random(bounds.Position.X-(bounds.Size.X/2),bounds.Position.X+(bounds.Size.X/2)),math.random(bounds.Position.Y-(bounds.Size.Y/2),bounds.Position.Y+(bounds.Size.Y/2)),math.random(bounds.Position.Z-(bounds.Size.Z/2),bounds.Position.Z+(bounds.Size.Z/2))
end