Fractions of a number

So I am busy making a script to split a part I will try to explain what I am trying to do.

In the picture there is a rectangle named “Part” it is the starting part.

The 2 halves are the 2 new parts.

The X is the ‘splitpoint’ idk what to call it.

The splitpoint is suppose to be the fraction of the Part.

So one half will be 1/2 of the part and the other half will be 1/2.

If the splitpoint was 3 on half would be 1/3 and the other would be 2/3.

I am wondering how I could do this.

So far I can split any sized part into 2:

function Split(Part)
	local Half1 = Instance.new("Part", workspace)
	Half1.Size = Vector3.new(Part.Size.X/2, Part.Size.Y, Part.Size.Z)
	Half1.Anchored = true
	Half1.BrickColor = BrickColor.Random()
	
	local Half2 = Instance.new("Part", workspace)
	Half2.Size = Vector3.new(Part.Size.X/2, Part.Size.Y, Part.Size.Z)
	Half2.Anchored = true
	Half2.BrickColor = BrickColor.Random()
	
	Half1.Position = Vector3.new(Part.Position.X + (Part.Size.X/4), Part.Position.Y, Part.Position.Z)
	Half2.Position = Vector3.new(Part.Position.X - (Part.Size.X/4) , Part.Position.Y, Part.Position.Z)
	
	Part:Destroy()
end

I could be wrong, but couldn’t you just union the parts? Instead of deleting the original part and making 2 new parts.

I dont know what you mean, I am taking a part and making 2 new parts but split by a fraction

Here’s how I got it to work:

function splitPart(part, fraction)
  assert(fraction > 0 and fraction < 1)
  
  local half1 = Instance.new("Part", workspace)
  half1.Size = Vector3.new(part.Size.X * fraction, part.Size.Y, part.Size.Z)
  half1.Anchored = true
  half1.BrickColor = BrickColor.Random()
  
  local half2 = Instance.new("Part", workspace)
  half2.Size = Vector3.new(part.Size.X * (1 - fraction), part.Size.Y, part.Size.Z)
  half2.Anchored = true
  half2.BrickColor = BrickColor.Random()
  
  half1.Position = part.Position + Vector3.new(half1.Size.X/2 - part.Size.X/2, 0, 0)
  half2.Position = part.Position + Vector3.new(-half2.Size.X/2 + part.Size.X/2, 0, 0)
  
  part:Destroy()
  return half1, half2
end

local part = game.Workspace.Part
for _ = 1, 5 do
  local p1, p2 = splitPart(part, math.random(25, 75)/100)
  if math.random() > 0.5 then
    part = p1
  else
    part = p2
  end
end

The math for figuring out the sides is fairly simple. If the fraction is 1/10, the first half should be 10% of the size and the other should be “the rest”, i.e. (1 - 1/10) of the size, so 90%.

For the positions, if we wanted to center the first part on the left-most side of the original part, it’d be like so:

half1.Position = part.Position + Vector3.new(-part.Size.X/2, 0, 0)

We don’t want that though, we want to move it back by half the size of the new part, so we get what I posted in the function above.

I tryed to make something, i dont know if it is what you wanted but here it is

function MakePart()
    local Part = Instance.new("Part")
    Part.Anchored = true
    Part.CanCollide = true
    Part.Parent = workspace
    Part.BrickColor = BrickColor.Random()

    return Part
end


function PartSplitter:Split(Part, x)
   if not Part or not x then warn("Missing argument") return end

   local Split1 = MakePart()
   local Split2 = MakePart()

   local SplitSize = Part.Size * Vector3.new(.5, 1, 1)

   local Divide = 1 / x
   local Rest = 1 - (1/x)

   Split1.Size = Part.Size * Vector3.new(Divide, 1, 1)
   Split2.Size = Part.Size * Vector3.new(Rest, 1, 1)

   Split1.CFrame = Part.CFrame * CFrame.new(Part.Size.X/2 * Rest,0,0) 
   Split2.CFrame = Part.CFrame * CFrame.new(-Part.Size.X/2 * Divide,0,0) 

   return {Split1, Split2}
end

if x is 2 then the first side is 1/2 and the second side is the rest
if x is 3 then the first side is 1/3 and the other side is the rest
and so on you get the deal

It looks like this:
https://i.gyazo.com/97434d3ed44d56c60a6014d6b548fdf0.mp4

Hope this helped