How to scale NPC models

Hi there :wave:, I have this npc model
image

And I want to scale this in-game through code.

To something like this.
image

I looked it up and found this post - Is this the best way to scale a model?

It didnt help much because my model will also have accessories.

I would like to know is there any api or function or anyway to set the size of a npc model ingame?

2 Likes

Have a look at this.

This wouldn’t work for him as it would not give him the desired result.
image
TestDummy uses the module, and my character uses scaling [hum:WaitForChild(‘BodyWidthScale’).Value]

The OP could just edit it to their needs…?

What I did is, I made clones of the model with the varying sizes and put them inside serverStorage because I couldn’t be bothered anymore. I hope one day roblox might add an API for model scaling.

1 Like

For future reference:

local scale = 2
local character = your_character_to_scale
local hum = character:WaitForChild("Humanoid")
hum:WaitForChild('BodyHeightScale').Value = scale
hum:WaitForChild('BodyDepthScale').Value = scale
hum:WaitForChild('BodyWidthScale').Value = scale
hum:WaitForChild('HeadScale').Value = scale

This should double the scale of your character, and don’t forget to change the humanoid hip height after you scale it.

3 Likes

Here’s the problem, NPCs don’t automatically have the NumberValues in them (or even StarterCharacters) so you’ll need to manually clone NumberValues with the names of the proportions and then the engine will automatically adjust the sizes of the NPC to them.

Here’s the function I use to scale rigs:

local function changeRigSize(rig,height,width,depth,headSize)
	local humanoid = rig:WaitForChild("Humanoid")
	if humanoid then
		if not (humanoid:FindFirstChild("BodyHeightScale")) then -- if it doesn't have this
			print("didn't find BodyHeightScale, making one!")
			local _bodyHeightScale = Instance.new("NumberValue")
			_bodyHeightScale.Name = "BodyHeightScale"
			_bodyHeightScale.Parent = humanoid
			_bodyHeightScale.Value = height
		else -- if it has it already
			print("found BodyHeightScale, scaling!")
			humanoid.BodyHeightScale.Value = height
		end
		if not (humanoid:FindFirstChild("BodyWidthScale")) then -- if it doesn't have this
			local _bodyWidthScale = Instance.new("NumberValue")
			_bodyWidthScale.Name = "BodyWidthScale"
			_bodyWidthScale.Parent = humanoid
			_bodyWidthScale.Value = width
		else -- if it has it already
			humanoid.BodyWidthScale.Value = width
		end
		if not (humanoid:FindFirstChild("BodyDepthScale")) then -- if it doesn't have this
			local _bodyDepthScale = Instance.new("NumberValue")
			_bodyDepthScale.Name = "BodyDepthScale"
			_bodyDepthScale.Parent = humanoid
			_bodyDepthScale.Value = depth
		else -- if it has it already
			humanoid.BodyDepthScale.Value = depth
		end
		if not (humanoid:FindFirstChild("HeadScale")) then -- if it doesn't have this
			local _headScale = Instance.new("NumberValue")
			_headScale.Name = "HeadScale"
			_headScale.Parent = humanoid
			_headScale.Value = headSize
		else -- if it has it already
			humanoid.HeadScale.Value = headSize
		end
	end
end
6 Likes

@FastAsFlash_Dev this is true, to scale a NPC you just need to add different NumberValues Instances in the Humanoid of the NPC, then you change the values and it will work. To try this out: Start a game in Roblox studio and go to your own Character Humanoid. You will see many NumberValues. Change them and you will scale your own body. This is how Lifting Simulator works for example. Just use the code of @SaltyPotter and see what @Captain_Teach wrote.

3 Likes

just use
NPC:ScaleTo(.1)

if its rigged properly it should work