Made a Plugin That Splits a Part Into Smaller Parts!

Hi friends,
Today, I was bored so I decided to make a plugin that split a part into tiny 1x1x1 parts.


I’m not really sure what this could be used for (lol) but if any of you guys have any use for it, the link is here:

https://www.roblox.com/library/4978762626/Part-Split-Plugin

Note: The plugin only works with small parts that’s side has no decimal places (example a part with the size 4x5x12 would work, but 4x5.3x12 would not work)
If a part is to big, it may take a while to run.

Hope this plugin helps!

BTW, it's all open sourced!

Probably not the most efficient code, but it gets the job done.

--Services:
local selectionService = game:GetService("Selection")

local toolbar = plugin:CreateToolbar("Split Part")
 
local customSplitButton = toolbar:CreateButton("Split a part", "Split a part in to 1x1x1 parts", "rbxassetid://4458901886")
 
--Run
local selected = nil

local newPart = nil

local cloneMe = nil

local model = nil

function createCustomsplit()
	selected = selectionService:Get()
	--print(selected[1].Size)
	
	model = Instance.new("Model", selected[1].Parent)
	model.Name = selected[1].Name
	
	cloneMe = Instance.new("Part")
	cloneMe.Size = Vector3.new(1, 1, 1)
	cloneMe.TopSurface = Enum.SurfaceType.Smooth
	cloneMe.BottomSurface = Enum.SurfaceType.Smooth
	cloneMe.Color = selected[1].Color
	cloneMe.Name = selected[1].Name .. "-Piece"
	cloneMe.Anchored = selected[1].Anchored
	cloneMe.CanCollide = selected[1].CanCollide
	cloneMe.Position = Vector3.new((selected[1].Position.X + selected[1].Size.X / 2) - 0.5, (selected[1].Position.Y + selected[1].Size.Y / 2) - 0.5, (selected[1].Position.Z + selected[1].Size.Z / 2) + 0.5)
	cloneMe.Material= selected[1].Material
	cloneMe.TopSurface = selected[1].TopSurface
	cloneMe.BottomSurface = selected[1].BottomSurface
	cloneMe.LeftSurface = selected[1].LeftSurface
	cloneMe.RightSurface = selected[1].RightSurface
	cloneMe.FrontSurface = selected[1].FrontSurface
	cloneMe.BackSurface = selected[1].BackSurface
	
	for x = 0, (selected[1].Size.X) - 1 do
		for y = 0, (selected[1].Size.Y) do
			for z = 0, (selected[1].Size.Z -1) do
				cloneMe.Position = Vector3.new(cloneMe.Position.X, cloneMe.Position.Y, cloneMe.Position.Z - 1)
				newPart = cloneMe:Clone()
				newPart.Parent = model
			end
			cloneMe.Position = Vector3.new((selected[1].Position.X + selected[1].Size.X / 2) - 0.5 - x, (selected[1].Position.Y + selected[1].Size.Y / 2) - 0.5 - y, (selected[1].Position.Z + selected[1].Size.Z / 2) + 0.5)
		end
		cloneMe.Position = Vector3.new((selected[1].Position.X + selected[1].Size.X / 2) - 0.5 - x, (selected[1].Position.Y + selected[1].Size.Y / 2) - 0.5, (selected[1].Position.Z + selected[1].Size.Z / 2) + 0.5)
	end
	
	cloneMe:Destroy()
	selected[1]:Destroy()
end

customSplitButton.Click:Connect(createCustomsplit)

If you do have a use for this plugin, tell me in the replies!
Also, please report any errors.

10 Likes

Nice, and thank you! I’ll try this out when I had free time!

1 Like

it really help if you wanna make pebble as well. good work :smiley:

1 Like

Thank you so much dude, you have no idea how long i’ve wanted this…