Sizing does not work

I build a game, but the player is too tiny, so I tried to resize the player * 2 but i cant :confused:
This is what I got

function PlayerSize(player)
local SizeValue = 2

local humanoid = game.Players.LocalPlayer.Character.Humanoid
if humanoid then
	if humanoid:FindFirstChild("BodyHeightScale") then
		humanoid.BodyHeightScale.Value = SizeValue
	end
	
	if humanoid:FindFirstChild("BodyWidthScale") then
		humanoid.BodyBodyWidthScaleScale.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

PlayerSize(game.Players.LocalPlayer)

The error message says: ServerScriptService.Script:4: attempt to index nil with ‘Character’

This is because you are trying to access the LocalPlayer property of Players on the server which is not possible.

But then, how do I make it so every player gets bigger when they join?

1 Like

Something like this should work:

local Players = game:GetService("Players")

function onPlayerAdded(player)
	local Character = player.Character

	--Check if their character has loaded yet
	if Character then
		onCharacterAdded(Character) 
	end
	
	-- Capture all other time their character is added
	player.CharacterAdded:Connect(onCharacterAdded)
end

function onCharacterAdded(character)
	-- Wait for their Humanoid and scaling values
	local Humanoid = character:WaitForChild("Humanoid") 

	local BodyHeightScale = Humanoid:WaitForChild("BodyHeightScale")
	local BodyWidthScale = Humanoid:WaitForChild("BodyWidthScale")
	local BodyDepthScale = Humanoid:WaitForChild("BodyDepthScale")
	local HeadScale = Humanoid:WaitForChild("HeadScale")

	--Set them to double the size
	BodyHeightScale.Value = 2
	BodyWidthScale.Value = 2
	BodyDepthScale.Value = 2
	HeadScale.Value = 2
end

for _, player in ipairs(Players:GetPlayers()) do -- For any players already in
	onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded) -- For all future players

Let me know if there’s any typos :slight_smile:

Well this “in” in line 31 has something wrong lol
ServerScriptService.Script:31: Expected ‘=’ when parsing assignment, got ‘in’

Looks like I missed a space, try adding one between for and _. The example has been updated.

I got a total blackout
“WaitForChildOfClass is not a valid member of Model”
How, I couldn’t find any Model

Oops, that isn’t a function haha. Change that to :WaitForChild("Humanoid").

Okay thank you so much! Finally got that :smiley:

1 Like