Hi! I am wondering how I split parts evenly. This is are exemplar videos of what I would want. Would I simply find the overall volume and split it how ever many times I want and thats the volume of the wanted part? Thanks - Lux
Decide the size of the parts you want to split into, calculate how many there will be in each direction, then create the parts inside for loops and place them accordingly.
Ok, I mean i get that but wait I think i have a idea… maybe a loop that goes all on the lower base, then it loops in a loop… waiitt…
local function Fill(part, size, parent)
local px, py, pz = part.Size.X, part.Size.Y, part.Size.Z;
local sx, sy, sz = size.X, size.Y, size.Z;
if (px % sx) and (py % sy) and (pz % sz) then
local ox, oy, oz = part.CFrame.X, part.CFrame.Y, part.CFrame.Z
local nx, ny, nz = (px / sx), (py / sy), (pz / sz);
for x = 1, nx do
for y = 1, ny do
for z = 1, nz do
local block = Instance.new("Part", parent)
block.Anchored = true
block.Size = size
block.BrickColor = BrickColor.Random()
block.CFrame = CFrame.new(
(ox + x) - ((px / 2) + (sx / 2)), -- Correct the X
(oy + y) - ((py / 2) + (sy / 2)), -- Correct the Y
(oz + z) - ((pz / 2) + (sz / 2)) -- Correct the Z
)
end
end
end
end
end
How would I make it so the part size is editable and doesn’t break it?
Just saying, this type of thing long-term on a server will be laggy as hell—especially if the parts are unanchored. Just a warning
Please specify “How would I make it so the part size is editable and doesn´t break it?”
I rewrote this differently because I was also interested in it, see if this does what you are asking about?
local function Divide(part, targetBlockSize)
local function Elw(vec, op)
return Vector3.new(op(vec.X), op(vec.Y), op(vec.Z))
end
local blockCount = Elw(part.Size, function(l) return math.floor(l / targetBlockSize) end)
local blockSize = part.Size / blockCount
for x = 1, blockCount.X do
for y = 1, blockCount.Y do
for z = 1, blockCount.Z do
local offset = (part.Size + blockSize) / 2.0
local block = Instance.new("Part", part.Parent)
block.Size = blockSize
block.CFrame = part.CFrame:ToWorldSpace(CFrame.new(Vector3.new(x,y,z) * blockSize - offset))
block.BrickColor =BrickColor.random()
block.Anchored = true
end
end
end
--part:Remove()
end
Holy, is there any way I can give $$ for this. Thank you so much!!!
No this took me two seconds as someone else asked the same thing right before you iirc.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.