Resing/scaling excess parts of Accessory

When you use the :AddAccessory function onto the humanoid, it only resizes the Handle to the appropriate scaling for the character, although it does not resize any other parts in the tool.
This would be fine, although my Accessory has extra parts that attached by welds.
I have tried it with all different kinds of welds, (Normal welds and weldconstraints)

image

What I am trying to achieve is a tool, that is on the left hand instead of right, the tool is attached by an Accessory and an animation is played to move the arm.

image

As you can see when I equip the tool, one part is smaller than the rest, that’s the handle as it has been resized from the characters size scale, but the other parts remain the same size, how else do you think I could possibly resize these other parts to match the Handle.

Personally I believe Roblox should add a feature that automatically resizes it along with the Handle, it is definitely possible as Tools do it.

Edit: Someone has half resolved this for me, they’ve shown me how to make tools attach to the left hand instead of the right, although I still need to find out how to resize the excess parts with the correct scale, because I am also wanting to create a cooking system.
In the cooking system, when your cooking, it attaches a item like a knife(Equipment used to cook), to the hand while doing a cooking animation, without having to be holding a tool.

Thanks for your help :slight_smile:

1 Like

Try using the AutomaticScalingEnabled property on the player’s humanoid.

Another alternative instead of using accessories would be to disable the backpack interface with CoreGui:SetCoreGuiEnabled() so that they can’t unequip it and then cloning and force equipping your tool. (assuming I understood your system correctly)

That would work and I may use that if no one finds a solution, I know it’s definitely possible because I have seen it in games, it’d be interesting to see a solution to this.

I bumped into this issue and ended up writing a function to manually scale the extra parts, run this function on the server after you have run humanoid:AddAccessory()

This will only work if you have welded using WeldConstraint, otherwise you need to change the script to update the Motor6D / Weld C0 instead of just moving the extra part of the accessory.

local function scaleAccessoryChildren(acc : Accessory)
	local scale = Vector3.new(
		acc.Handle.Size.X / acc.Handle.OriginalSize.Value.X,
		acc.Handle.Size.Y / acc.Handle.OriginalSize.Value.Y,
		acc.Handle.Size.Z / acc.Handle.OriginalSize.Value.Z
	)

	local baseCFrame = acc.Handle.CFrame :: CFrame

	for _, child in pairs(acc:GetDescendants()) do
		if child.Name == "Handle" then
			continue
		end
		
		if child:IsA("BasePart") then
			child.Size = Vector3.new(
				child.Size.X * scale.X,
				child.Size.Y * scale.Y,
				child.Size.Z * scale.Z
			)

			local relativePos = baseCFrame:PointToObjectSpace(child.Position)
			local scaledRelativePos = relativePos * scale

			local diffVector = Vector3.new(
				scaledRelativePos.X - relativePos.X,
				scaledRelativePos.Y - relativePos.Y,
				scaledRelativePos.Z - relativePos.Z				
			)

			child.Position += diffVector		
		end
	end
end