Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I access BodyDepthScale and other values in Humanoid?

I don't know much about scripting but I have a StarterCharacter that I want to change size once the player joins, I tried this

game.StarterPlayer.StarterCharacter.Humanoid.BodyDepthScale = 2

But it didn't work, any help?

1 comment

0

also next time you ask a question, please put it in a code block (select code and click lua icon thingy) or inline code (surround in grave "`" characters)

2 answers

✓ Accepted answer

first of all, the StarterPlayer instance is only used for cloning its contents to the appropriate places when a character or player is loaded into the game, so assuming the script is a normal server-sided "Script" in StarterCharacterScripts this script would be inside the character model in workspace, so that typing in:

script

would be equivilant of typing:

game.Workspace.<your username>.<name of script>

which is one important thing your missing.

Second of all, "BodyDepthScale" is actually a NumberValue instance, just like any instance, setting the entire class to a number or anything else is like deleting it from the world, the number in which you seek to change, is actually a property of BodyDepthScale.

--WRONG
script.Parent.Humanoid.BodyDepthScale = 489056198 --AAAAA bodydepthcale is gone *crab rave*

--CORRECT
script.Parent.Humanoid.BodyDepthScale.Value = 100000000 -- AAAA IM LONG NOW

Third of all, if you are immediately trying to access the character's children instances, they may have not yet loaded in, so you might wanna wait for them to load first:

local Humanoid = script.Parent:WaitForChild("Humanoid")
local BDS = Humanoid:WaitForChild("BodyDepthScale")

BDS.Value = math.inf -- ok dont actually set the depth to infinity that might be bad.

You are not accessing player itself, to do so. here is a way to do so. Script (so changing size won't be local)

event.OnServerEvent:Connect(function(player))
	player.Humanoid.BodyDepthScale = 2
	-- and such
end

LocalScript

event:FireServer()

this is pretty much the code

This discussion is preserved as it was. New answers, comments, and votes are closed.