There could be a lot of different ways to do this, but here's a simple one. I nested 2 for loops inside a while loop. So what this will do is create a part at (1,0,1), (1,0,2), (1,0,3), (2,0,1), etc. Until (3,0,3) and repeat. This is fairly flexible and very easy to understand.
I'd recommend adding a check to see if the previous block still exists in workplace though.
while true do
for xx = 1, 3, 1 do
for zz = 1, 3, 1 do
wait(1)
local partadded = Instance.new("Part")
partadded.Name = "Block"
partadded.Parent = game.Workspace
partadded.Position = Vector3.new(xx,0,zz)
end
end
end
EDIT: This should do roughly what you're looking for.
local positions = {
{['name'] = 'Part1', ['pos'] = Vector3.new(1,0,1)},
{['name'] = 'Part2', ['pos'] = Vector3.new(1,0,2)},
{['name'] = 'Part3', ['pos'] = Vector3.new(3,0,3)},
{['name'] = 'Part4', ['pos'] = Vector3.new(4,0,2)},
{['name'] = 'Part5', ['pos'] = Vector3.new(5,0,3)},
}
while wait(3) do
local rand = math.random(#positions)
if not workspace:FindFirstChild(positions[rand]['name']) then
local partadded = Instance.new("Part")
partadded.Name = positions[rand]['name']
partadded.Parent = workspace
partadded.Position = positions[rand]['pos']
end
end
5 comments
So what you wanna do is spawn blocks in a certain area?
Yes
Added an edit onto the answer.
You should try using reigon3 or zone+ or raycasting for a certain area
Here is a gif using zone+ similar to what you wanna do https://i.imgur.com/ZUS5xhQ.gif