I want to make an effect that when you click a part, a new part that is cut out from the original part is made.
For example:
gyazo link of what I am trying to do
local cd = script.Parent.ClickDetector
local part = script.Parent
local v3 = Vector3
function divide(brick, mousepos)
local maxSize = brick.Size - v3.new(2,2,2)
local newPart = brick:Clone()
newPart.Size = v3.new(math.random(1, maxSize.X),math.random(1, maxSize.Y),math.random(1, maxSize.Z))
newPart.CFrame = CFrame.new(mousepos)
newPart.CanCollide = false
newPart.Anchored = false
newPart.Parent = workspace
newPart.ClickDetector:Destroy()
local bv = Instance.new("BodyVelocity")
bv.MaxForce = v3.new(1,1,1) * math.huge
bv.Velocity = newPart.CFrame.lookVector * -1.1
bv.Parent = newPart
end
cd.MouseClick:Connect(function(player)
local mouse = player:GetMouse()
divide(part, mouse.Hit.p)
end)
Edit: I removed the click detector and detected clicking from a local script but I still need help with the concept of cutting the part.
This is the code I have. I randomize a section of the original part (called brick in the function), then I make a clone of the original part and place it where the player clicked then I instanced body velocity so I can see the new parts. I still need to cut out the sections from the original part.
Thanks for reading and any help will be greatly appreciated.

1 comment
You can't get the mouse from the server.