I Need help with my Size Script

Hello! Im trying to make a scale script for all of the players that play my game.

The Issue Is I want it to make me small ( 0.5 ) but It wont work at all and I don’t know what Im doing wrong also I want it to do it with all of the parts with the players avatar, I tried another script but It didn’t work. I also wanna make it so when you die your the same size.

function PlayerSize(player)
	local	SizeValue = 0.5

	local humanoid = player.Character.Humanoid
	if humanoid then
		if humanoid:FindFirstChild("BodyHeightScale")then
			humanoid.BodyHeightScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyWidthtScale")then
			humanoid.BodyWidthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyDepthScale")then
			humanoid.BodyDepthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("HeadScale")then
			humanoid.HeadScale.Value = SizeValue
		end
	end
end

wait(1)
for i, player in pairs(game.Players:GetPlayers()) do
	PlayerSize(player)
end

I Couldn’t find any solutions to help.

1 Like

Need a little more information than “it won’t work”. The code looks fine. What does your output window say? Nothing? Errors? Where is the script sitting? Workspace? ReplicatedStorage? ServerScriptService? Is it a local script or a server script?

1 Like

I just tested this and it works:

function PlayerSize(player)
	local	SizeValue = 0.5
	
	local char=player.Character or player.CharacterAdded:wait()
	local humanoid = char:WaitForChild("Humanoid")
	if humanoid then
		if humanoid:FindFirstChild("BodyHeightScale")then
			humanoid.BodyHeightScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyWidthtScale")then
			humanoid.BodyWidthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyDepthScale")then
			humanoid.BodyDepthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("HeadScale")then
			humanoid.HeadScale.Value = SizeValue
		end
	end
end

wait(1)
for i, player in pairs(game.Players:GetPlayers()) do
	PlayerSize(player)
end

The only thing I added to your existing code was this line:

local char=player.Character or player.CharacterAdded:wait()
1 Like

The loop at the end is probably not the best approach to solving this problem. Alternatively, you can do something like this :

local Players = game:GetService:Players()
Players.PlayerAdded:Connect(function(plr)
     plr.CharacterAdded:Connect(function(char)
            PlayerSize(char)
     end)
end)

In this case, you’ll need to modify the PlayerSize function to take a character as the argument instead of a player, like so:

function PlayerSize(char)
    local SizeValue = 0.5
	local humanoid = char:FindFirstChild("Humanoid")
	if humanoid then
		if humanoid:FindFirstChild("BodyHeightScale")then
			humanoid.BodyHeightScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyWidthtScale")then
			humanoid.BodyWidthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyDepthScale")then
			humanoid.BodyDepthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("HeadScale")then
			humanoid.HeadScale.Value = SizeValue
		end
	end
end
1 Like

It’s not my code, I just copy/pasted what the poster had already scripted with an edit to make it work for them.

1 Like

Oops, did not mean to type that as a reply. That was meant to be a response to the original thread. My mistake.

3 Likes
  13:08:28.970  ServerScriptService.Script:4: attempt to index nil with 'Humanoid'  -  Server  -  Script:4
  13:08:28.970  Stack Begin  -  Studio
  13:08:28.970  Script 'ServerScriptService.Script', Line 4 - function PlayerSize  -  Studio  -  Script:4
  13:08:28.970  Script 'ServerScriptService.Script', Line 23  -  Studio  -  Script:23
  13:08:28.971  Stack End  -  Studio

This error happens because the character has not loaded when the function is called, so using the “.” operator will result in an error because the player’s character does not presently exist. See my earlier post and try that approach, or use:

local char = plr.Character or plr.CharacterAdded:Wait()

as @ZombieCrunchUK suggested.

2 Likes

Screenshot 2021-01-16 141330

Why am I fat I wanted all of my body to be 0.5

No idea. Is it a custom character?
I tested the code with my default roblox avatar (r15) and proportions were fine.

Mine Is R15 rn, also no Its not a custom character, my avatar is changed but devforum doesnt load you changed after that long

You will have to give it time for your character’s content to load. You are getting that weird body effect because your bodyheight, bodydepth, and headscales load in before your bodywidth. Instead of :FindFirstChild(), try using :WaitForChild()

This also applies to
local humanoid = char:FindFirstChild("Humanoid")

local humanoid = char:WaitForChild("Humanoid")

1 Like

Use this:

function Size(Player)
	local Char = Player.Character or Player.CharacterAdded:wait()
    local Humanoid = Char:WaitForChild("Humanoid")

    local BodyHeightScale = Humanoid:WaitForChild("BodyHeightScale")
    local BodyDepthScale = Humanoid:WaitForChild("BodyDepthScale")
	local BodyWidthScale = Humanoid:WaitForChild("BodyWidthScale")
	local HeadScale = Humanoid:WaitForChild("HeadScale")
	
    BodyHeightScale.Value = 0.525 
    BodyDepthScale.Value = 0.5
    BodyWidthScale.Value = 0.5
    HeadScale.Value = 0.5
end
1 Like

didint do anything at all it just kinda was their and didnt size the character

Its already Inside their

function PlayerSize(player)
	local	SizeValue = 0.5

	local char=player.Character or player.CharacterAdded:wait()
	local humanoid = char:WaitForChild("Humanoid")
	if humanoid then
		if humanoid:FindFirstChild("BodyHeightScale")then
			humanoid.BodyHeightScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyWidthtScale")then
			humanoid.BodyWidthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyDepthScale")then
			humanoid.BodyDepthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("HeadScale")then
			humanoid.HeadScale.Value = SizeValue
		end
	end
end

wait(1)
for i, player in pairs(game.Players:GetPlayers()) do
	PlayerSize(player)
end
local function PlayerSize(char)
	local SizeValue = 0.5

	local humanoid = char:WaitForChild("Humanoid")
	if humanoid then
		if humanoid:FindFirstChild("BodyHeightScale") then
			humanoid.BodyHeightScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyWidthtScale") then
			humanoid.BodyWidthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("BodyDepthScale") then
			humanoid.BodyDepthScale.Value = SizeValue
		end
		if humanoid:FindFirstChild("HeadScale") then
			humanoid.HeadScale.Value = SizeValue
		end
	end
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		PlayerSize(char)
	end)
end)

The issue is that you tried to get the character AND the humanoid straight away, while none of those have loaded yet. You can use the PlayerAdded event to get when a player joins, and the CharacterAdded event of the player to get whenever the player loads (including when a player dies)

(If you don’t know what an event is, click here)

1 Like

Oh! Then it’s fixed.
Why was the solution not marked?

1 Like

Its still not working, Im still fat for no reason it doesnt size my chest

I think I found the problem.
Can you send a capture of the descendants of the humanoid?

1 Like

Your humanoid, please.
Maybe something is missing.

1 Like