I cannot change avatar size

Hi there! I made a regular script which should make change avatar size but It don’t work. Here is the line of script:

local function ChangePlayerSize(player)
	local human = player.character.Humanoid
	if human then
		local h = human.HeadScale
		local bd = human.BodyDepthScale
		local bw = human.BodyWidthScale
		local bh = human.BodyHeightScale
		
		h.Value += 1
		bd.Value += 1
		bw.Value += 1
		bh.Value += 1	
	end
end

Can you help me please? I don’t know what is wrong.

Is this the whole script? if so then you need to do

local function ChangePlayerSize(player)
	local human = player.character.Humanoid
	if human then
		local h = human.HeadScale
		local bd = human.BodyDepthScale
		local bw = human.BodyWidthScale
		local bh = human.BodyHeightScale
		
		h.Value += 1
		bd.Value += 1
		bw.Value += 1
		bh.Value += 1	
	end
end

game.Players.PlayerAdded:Connect(function(player)
   ChangePlayerSize(player)
end)

Not sure on that one but I’ve always been using the Character property of player, as in with an uppercased C, and I don’t think a character (with lowercased C) property exists. Try changing local human = player.character.Humanoid to local human = player.Character.Humanoid

It probably doesn’t work because the humanoid doesn’t exist yet, you can use Instance | Roblox Creator Documentation to wait for the instance to exist.

local function ChangePlayerSize(player)
	if not player.Character then
		player.CharacterAdded:Wait()
	end
	local human = player.Character:WaitForChild("Humanoid")
	local h = human.HeadScale
	local bd = human.BodyDepthScale
	local bw = human.BodyWidthScale
	local bh = human.BodyHeightScale

	h.Value += 1
	bd.Value += 1
	bw.Value += 1
	bh.Value += 1	
end
1 Like

This won’t do it either. The function will be executed only when someone enters the game, but not whenever their character spawns. You’ll have to hook OP’s function to a CharacterAdded event listener:

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        ChangePlayerSize(player)
    end)
end)

Full script:

local function ChangePlayerSize(player)
	local human = player.Character and player.Character:FindFirstChild("Humanoid")
	if human then
		local h = human.HeadScale
		local bd = human.BodyDepthScale
		local bw = human.BodyWidthScale
		local bh = human.BodyHeightScale
		
		h.Value += 1
		bd.Value += 1
		bw.Value += 1
		bh.Value += 1	
	end
end

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        ChangePlayerSize(player)
    end)
end)

First, the script I showed isn’t the entire script. It was juste a function.

Also, my character is set by default. It haven’t been modified with another script.

Finally, when the script execute the function and the player is me, there are an error message. It’s written this:
HeadScale is not a valid member of Humanoid “Workspace.Azerty_103.Humanoid”

Pretty sure this can easily be fixed using WaitForChild

local h = human:WaitForChild("HeadScale")
local bd = human:WaitForChild("BodyDepthScale")
local bw = human:WaitForChild("BodyWidthScale")
local bh = human:WaitForChild("BodyHeightScale")

When I use the script in R6, there are this error message:
Infinite yield possible on ‘Workspace.Azerty_103.Humanoid:WaitForChild(“HeadScale”)’

I tried this script in R15. It worked. My script didn’t worked because I was in R6.

But I would like to know how to change player size in R6.

With help from this post I was able to create a module able to scale both R15 and R6:
ModuleScript(named Resizer inside script)

local Players = game:GetService("Players")

local module = {}
module.defaultWait = 5

function module.R6Scale(character, multiplier)
	local function ApplyMotorScale(motor)
		local pos0, pos1 = motor.C0.Position, motor.C1.Position
		motor.C0 = CFrame.new((pos0 * multiplier)) * (motor.C0 - pos0)
		motor.C1 = CFrame.new((pos1 * multiplier)) * (motor.C1 - pos1)
	end
	
	ApplyMotorScale(character.HumanoidRootPart.RootJoint)
	for i, motor in pairs(character.Torso:GetChildren()) do
		if motor:IsA("Motor6D") then
			ApplyMotorScale(motor)
		end
	end
	
	for i, part in pairs(character:GetChildren()) do
		if part:IsA("BasePart") then 
			part.Size *= multiplier
		end
	end
	
	local player = Players:GetPlayerFromCharacter(character) 
	if player then 
		--wait for their accessories to load
		local loaded = player:HasAppearanceLoaded() or player.CharacterAppearanceLoaded:Wait()
	end
	for i, accessory in pairs(character:GetChildren()) do
		if not accessory:IsA("Accessory") then continue end 
		local Handle = accessory:FindFirstChild("Handle")
		if not Handle then continue end 
		local aw = Handle:FindFirstChild("AccessoryWeld")
		if not aw then continue end 
		aw.C0 = CFrame.new((aw.C0.Position * multiplier)) * (aw.C0 - aw.C0.Position)
		aw.C1 = CFrame.new((aw.C1.Position * multiplier)) * (aw.C1 - aw.C1.Position)
		local sm = Handle:FindFirstChildOfClass("SpecialMesh")
		if not sm then continue end 
		sm.Scale *= multiplier 
	end
end

function module.R15Scale(character, multiplier, waitTimeout)
	waitTimeout = waitTimeout or module.defaultWait
	
	local humanoid = character:FindFirstChild("Humanoid")
	if not humanoid then warn("Humanoid wasn't found") return end 
	local scales = {"HeadScale", "BodyDepthScale", "BodyWidthScale", "BodyHeightScale"}
	
	for _, scale in pairs(scales) do 
		local object = humanoid:WaitForChild(scale, waitTimeout)
		if not object then warn(scale.." wasn't found") continue end 
		object.Value *= multiplier 
	end
end

function module.Scale(character, multiplier, waitTimeout)
	waitTimeout = waitTimeout or module.defaultWait
	
	local humanoid = character:WaitForChild("Humanoid", waitTimeout) 
	if humanoid.RigType == Enum.HumanoidRigType.R15 then 
		module.R15Scale(character, multiplier, waitTimeout)
	else 
		module.R6Scale(character, multiplier)
	end
end

return module

Using it

--script inside StarterCharacterScripts
local Character = script.Parent 

local Percentage = 5

local Resizer = require(script:WaitForChild("Resizer"))
Resizer.Scale(Character, Percentage)
4 Likes