Troubles with resizing 3D Shirts & Pants with humanoid scales

I’ve successfully accomplished welding 3D Clothing to the character for my character customization, but I wanna add height, depth, width scaling to it aswell. And that’s where my problem occurs.

Without messing with height:
image

With messing with height:
image

The way I handle this system is shown in the following pictures:
image

Each part has a weld in it with a set C0, and then in the script I set it like this:
image

That is all I have for the default welding. From now on this goes into my theoretic code for scaling depending on the scale values.

So I update the clothing with a function I made whenever I set the clothing:

local ShirtModel = CustomizationAssets.Shirts["Shirt"..Number]:Clone()			
updateClothing(Character, ShirtModel, Type)
ShirtModel.Parent = Character

The function I made is:

local axisTable = {
	["BodyWidthScale"] = "X";
	["BodyHeightScale"] = "Y";
	["BodyDepthScale"] = "Z"
}

local function updateClothing(Character, Model, Type)
	local Humanoid = Character:FindFirstChild("Humanoid")
	if not Humanoid then return end
	
	for Index,Axis in pairs(axisTable) do
		ScaleClothing(Character, Model, Humanoid[Index], Humanoid[Index].Value)
	end
	
	for _,Object in ipairs(Model:GetChildren()) do
		Object.Weld.Part0 = Object
		Object.Weld.Part1 = Character[Object.Name]
	end
end

ScaleClothing function I made sometime ago:

local vectorTable = {
	["X"] = 1;
	["Y"] = 2;
	["Z"] = 3
}

local axisTable = {
	["BodyWidthScale"] = "X";
	["BodyHeightScale"] = "Y";
	["BodyDepthScale"] = "Z"
}

local newVectors = {}
local function ScaleClothing(character, model, _type, scale) 
	for index, object in ipairs(model:GetDescendants()) do
		if object:IsA("BasePart") then
			if axisTable[_type] == "X" then
				newVectors["X"] = object.Size.X*scale
			elseif axisTable[_type] == "Y" then
				newVectors["Y"] = object.Size.Y*scale
			elseif axisTable[_type] == "Z" then
				newVectors["Z"] = object.Size.Z*scale
			end

			if not newVectors["X"] then
				newVectors["X"] = object.Size.X
			end    
			if not newVectors["Y"] then
				newVectors["Y"] = object.Size.Y
			end    
			if not newVectors["Z"] then
				newVectors["Z"] = object.Size.Z
			end	
			object.Size = Vector3.new(newVectors["X"],newVectors["Y"],newVectors["Z"])			
			newVectors = {}
		end
	end
end

And the result is what I showed earlier whenever I change the height and rescale. I’m pretty clueless on a fix I’ve been trying for a while to come up with a solution but just couldn’t. Anybody has some insight they could share, or possibly a fix?

1 Like