Help with splitting a part

I have been up for a few hours trying to solve this problem and I still cant quite figure it out. I have made a function that in theory should split a part into 2 separate parts but for some reason the script fails to resize the part. Any help would be much appreciated.

function split(part, face, delta)
	local f1, f2, d = nil, nil, nil
	if face == "X" then
		f1, f2, d = Enum.NormalId.Left, Enum.NormalId.Right, part.Size.X
	elseif face == "Y" then
		f1, f2, d = Enum.NormalId.Top, Enum.NormalId.Bottom, part.Size.Y
	elseif face == "Z" then
		f1, f2, d = Enum.NormalId.Front, Enum.NormalId.Back, part.Size.Z
	else
		error("Face not provided")
	end
	local p = part:Clone()
	p.Parent = part.Parent
	p:Resize(f1, -(d-delta*d))
	local p = part:Clone()
	p.Parent = part.Parent
	p:Resize(f2, -(d-(1-delta)*d))
	print(-(d-delta*d), -(d-(1-delta)*d))
	part:Destroy()
end

wait(5)
split(workspace.Part, "X", 0.75)

Okay first off I have no idea what you are even trying to do, so like give me more context on this

what exactly happens (or not) when you run the script?

And for others who don’t understand what is he trying to achieve imma say it. He wants to take a 4 * 2 * 3 part and cut it on the x axis at 75% of it’s length(for example). The result of it will be two parts one with the 3 * 2 * 3 size and one with 1 * 2 * 3 size.

Please give a clear explanation of what your trying to do.

I did explain what he wants in my edit :slight_smile:

If he wants to do that he can just create 2 new parts defined as the same properties he had except for a change dependent on half of the delta difference before the cut operation which is just 4 * 0.75 with a x movement of 0.5 since 1 delta difference on x

1 Like

Yes thats exactly what im trying to do.

Yes thats what the :Resize is supposed to do but currently it does nothing, when the script runs it just creates 2 new parts in the exact same position and size as the old one.

Make sure to move them by half the scale factor you did

Yes even if I did that, it still does nothing so thats a problem I can deal with later

I tested your script, and it worked. All you have to do next is move the parts where they should be.