I would like to generate a large mass of blocks out of smaller blocks, for a building game to allow players to quickly add masses of parts (Why I want to make them out of smaller parts has to do with the way combat works) and the math on how to do this is lost on me.
I have been thinking of take the X Y and Z of a CFrame or V3 that the player enters and generating it like that in rows, but I do not even know how to spawn a part right beside another (almost like using a dragger tool to place the part at the exact position.)
Besides just compromising and making a different way of dealing damage so that the number of parts doesnt matter, how could I go about doing this?
(My math is atrocious due to a bunch of home life factors, so if you could explain the logic in laymans terms it would be very appreciated)
Here's a small script that does what you want. There is a problem at Part.CanCollide = false
. If you set it to true, the Parts don't line up as they should, but other than that, I think you're in the right direction with this script. Maybe someone else knows a way to bypass this.
local start = Vector3.new() local blockSize = 2 local rowCount = 5 local posX = start.X local posY = start.Y local posZ = start.Z local Model = Instance.new("Model", Workspace) Model.Name = "Block" for x = 1, rowCount do for y = 1, rowCount do for z = 1, rowCount do local Part = Instance.new("Part", Model) Part.CanCollide = false Part.Anchored = true Part.Position = Vector3.new(posX, posY, posZ) Part.Size = Vector3.new(blockSize, blockSize, blockSize) posZ = posZ + blockSize end posZ = start.Z posY = posY + blockSize end posY = start.Y posX = posX + blockSize end