Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I access BodyDepthScale and other values in Humanoid?

Asked by 4 years ago

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?

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) fanofpixels 718 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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.
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

Answer this question