Assistance needed with scaling accessories

Hello. I made this script where you could rescale your character on the Y axis with a value and it would rescale on the X and Z axis with another value. The thing that I am struggling with is scaling the accessories with the wanted character scale on the X and Z axis.

The scaling issue worsens when trying to scale it multiple times:

(Me scaling down - .03 once from max)

image

(Me scaling up .03 once from max)

image

Here is the code of the script right here

-- // Services

local Players = game:GetService("Players")

local CFrameModule = require(script:FindFirstChild("DefaultCFs"))

-- // Height Setup

local MinHeight = 1

local MaxHeight = 1.55

function GetHeight(Wanted)

	return math.clamp( (Wanted / 1), MinHeight, MaxHeight)

end

-- // Weight Setup

local MinWeight = .8

local MaxWeight = 1.14

function GetWeight(Wanted, Height)

	return math.clamp( Wanted , MinWeight, MaxWeight)

end

Players.PlayerAdded:Connect(function(Player)

	Player:SetAttribute("Height", 1)

	Player:SetAttribute("Weight", 1)

	local V = Vector3.new(GetWeight(Player:GetAttribute("Weight"), Player:GetAttribute("Height")), GetHeight(Player:GetAttribute("Height")), GetWeight(Player:GetAttribute("Weight"), Player:GetAttribute("Height")))
	
	local PreviousHeight, PreviousWeight = Player:GetAttribute("Height"), Player:GetAttribute("Weight")
	
	Player.CharacterAdded:Connect(function(Character)

		-- // Welds

		local Welds = {}

		for _, Weld in pairs(Character:FindFirstChild("Torso"):GetChildren()) do
			if Weld:IsA("Motor6D") then
				if string.find(Weld.Name, "Hip") then

					table.insert(Welds, Weld)

				end
			end
		end

		-- // Height 

		for Part, Size in pairs(CFrameModule.DefaultParts) do

			Character[Part].Size = Size * V

		end

		-- // Welding

		for Motor, C0 in pairs(CFrameModule.DefaultC0) do

			if Motor == 'Neck' then

				Character.Torso[Motor].C0 = CFrame.new((C0.Position * Vector3.new(V.X, V.Y / 2 + .5, V.Z))) * (C0 - C0.Position)

			else

				Character.Torso[Motor].C0 = CFrame.new((C0.Position * V)) * (C0 - C0.Position)

			end

		end

		for Motor, C1 in pairs(CFrameModule.DefaultC1) do

			Character.Torso[Motor].C1 = CFrame.new((C1.Position * V)) * (C1 - C1.Position)

		end

		-- // Constant Update \\ --

		for Name, Value in pairs(Player:GetAttributes()) do

			Player:GetAttributeChangedSignal(Name):Connect(function()
				
				if Player:GetAttribute("Height") >= MaxHeight then

					Player:SetAttribute("Height", MaxHeight)

				elseif Player:GetAttribute("Weight") >= MaxWeight then

					Player:SetAttribute("Weight", MaxWeight)

				end

				V = Vector3.new(GetWeight(Player:GetAttribute("Weight"), Player:GetAttribute("Height")), GetHeight(Player:GetAttribute("Height")), GetWeight(Player:GetAttribute("Weight"), Player:GetAttribute("Height")))
				
				print(PreviousHeight, PreviousWeight)
				
				-- // Height 

				for Part, Size in pairs(CFrameModule.DefaultParts) do

					Character[Part].Size = Size * V

				end

				-- // Welding

				for Motor, C0 in pairs(CFrameModule.DefaultC0) do

					if Motor == 'Neck' then

						Character.Torso[Motor].C0 = CFrame.new((C0.Position * Vector3.new(V.X, V.Y / 2 + .5, V.Z))) * (C0 - C0.Position)

					else

						Character.Torso[Motor].C0 = CFrame.new((C0.Position * V)) * (C0 - C0.Position)

					end

				end

				for Motor, C1 in pairs(CFrameModule.DefaultC1) do

					Character.Torso[Motor].C1 = CFrame.new((C1.Position * V)) * (C1 - C1.Position)

				end

				-- // Accessory scaling

				for _, Accessory in pairs(Character:GetChildren()) do
					if Accessory:IsA("Accessory") then
						
						Accessory.Handle.AccessoryWeld.C0 = CFrame.new((Accessory.Handle.AccessoryWeld.C0.Position * V)) * (Accessory.Handle.AccessoryWeld.C0 - Accessory.Handle.AccessoryWeld.C0.Position)
						Accessory.Handle.AccessoryWeld.C1 = CFrame.new((Accessory.Handle.AccessoryWeld.C1.Position * V)) * (Accessory.Handle.AccessoryWeld.C1 - Accessory.Handle.AccessoryWeld.C1.Position)

						local AccessoryMesh = Accessory.Handle:FindFirstChild("Mesh")
						
						if AccessoryMesh then
							
							local OriginalMeshScale = Vector3.new(Accessory.Handle.Mesh.Scale.X / PreviousWeight, Accessory.Handle.Mesh.Scale.Y / PreviousHeight, Accessory.Handle.Mesh.Scale.Z / PreviousWeight)
							
							Accessory.Handle.Mesh.Scale *= Vector3.new(OriginalMeshScale.X * V.X, OriginalMeshScale.Y * V.Y, OriginalMeshScale.Z * V.Z)
							
						end

						local AccessoryPart = Accessory.Handle:FindFirstChild("Part")
						
						if AccessoryPart then
							
							local OriginalPartScale = Vector3.new(Accessory.Handle.Part.Scale.X / PreviousWeight, Accessory.Handle.Part.Scale.Y / PreviousHeight, Accessory.Handle.Part.Scale.Z / PreviousWeight)
							
							Accessory.Handle.Part.Scale *= Vector3.new(OriginalPartScale.X * V.X, OriginalPartScale.Y * V.Y, OriginalPartScale.Z * V.Z)
							
						end

					end

				end
				
				PreviousHeight = Player:GetAttribute("Height")

				PreviousWeight = Player:GetAttribute("Weight")

			end)

		end

	end)



end)

Help is appreciated.

See this: Player body parts resizing help - #2 by Forummer

Iā€™m trying to rescale the accessories, I have already achieved R6 rig rescaling.

There is a resize model that does this, let me find it
Edit: found it: Character Scaling (R6 and R15) - Roblox

I just made my own solution by just not scaling the head, thanks for the replies.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.