How to resize an R6 NPC?

Apparently scaling only applies to R15 rigs, is there any way to resize an R6 one?

Basically, I need this NPC to become 2x larger in-game.

1 Like

So I found out 2 ways. You can already have a copy of the larger NPC and just clone it and position it to where the original was,
OR do a roundabout way of scaling each part, then positioning each part, scaling the joints, and positioning the joints.

I was going to make my own, but ironically there is a working one made by SolarCrane from this broken gear: Zombification Injection - Roblox

local function findObjectHelper(model, objectName, className, listOfFoundObjects)
	if not model then return end
	local findStart, findEnd = string.find(model.Name, objectName)
	if findStart == 1 and findEnd == #(model.Name) then  -- must match entire name
		if not className or model.className == className or (pcall(model.IsA, model, className) and model:IsA(className)) then
			table.insert(listOfFoundObjects, model)
		end
	end
	if pcall(model.GetChildren, model) then
		local modelChildren = model:GetChildren()
		for i = 1, #modelChildren do
			-- make sure not to resize tools, things tend to get complicated if we do
			if not (pcall(modelChildren[i].IsA, modelChildren[i], 'Tool') and modelChildren[i]:IsA('Tool')) then
				findObjectHelper(modelChildren[i], objectName, className, listOfFoundObjects)
			end
		end
	end
end

local function resizeModelInternal(model, resizeFactor)
	local modelCFrame = model:GetModelCFrame()
	local modelSize = model:GetModelSize()
	local baseParts = {}
	local basePartCFrames = {}
	local joints = {}
	local jointParents = {}
	local meshes = {}

	findObjectHelper(model, ".*", "BasePart", baseParts)
	findObjectHelper(model, ".*", "JointInstance", joints)

	-- meshes don't inherit from anything accessible?
	findObjectHelper(model, ".*", "FileMesh", meshes)                    -- base class for SpecialMesh and FileMesh
	findObjectHelper(model, ".*", "CylinderMesh", meshes)
	findObjectHelper(model, ".*", "BlockMesh", meshes)

	-- store the CFrames, so our other changes don't rearrange stuff
	for _, basePart in pairs(baseParts) do
		basePartCFrames[basePart] = basePart.CFrame
	end

	-- scale meshes
	for _,mesh in pairs(meshes) do
		-- This is a nasty hack because head meshes scale relative to the part's size
		-- thus scaling the mesh and the head gives u 2x the size
		if mesh.Parent.Name ~= "Head" then
			mesh.Scale = mesh.Scale * resizeFactor
		end
	end

	-- scale joints
	for _, joint in pairs(joints) do
		joint.C0 = joint.C0 + (joint.C0.p) * (resizeFactor - 1)
		joint.C1 = joint.C1 + (joint.C1.p) * (resizeFactor - 1)
		jointParents[joint] = joint.Parent
	end

	-- scale parts and reposition them within the model
	for _, basePart in pairs(baseParts) do
		if pcall(function() basePart.FormFactor = "Custom" end) then basePart.FormFactor = "Custom" end
		basePart.Size = basePart.Size * resizeFactor
		local oldCFrame = basePartCFrames[basePart]
		local oldPositionInModel = modelCFrame:pointToObjectSpace(oldCFrame.p)
		local distanceFromCorner = oldPositionInModel + modelSize/2
		distanceFromCorner = distanceFromCorner * resizeFactor

		local newPositionInSpace = modelCFrame:pointToWorldSpace(distanceFromCorner - modelSize/2)
		basePart.CFrame = oldCFrame - oldCFrame.p + newPositionInSpace
	end

	-- pop the joints back, because they prolly got borked
	for _, joint in pairs(joints) do
		joint.Parent = jointParents[joint]
	end

	return model
end

local function resizeImplementation(modelList, resizeFactor)
	if type(modelList) ~= "table" then modelList = {modelList} end

	for _, model in pairs(modelList) do
		--if model.Name ~= "BackPack" then
		resizeModelInternal(model, resizeFactor)
		--end
	end
	return modelList
end

resizeImplementation(character, 2) -- resize factor
5 Likes