Changing Character Height Not Working

My script which changes the character’s height based on their height leaderstat. Anyways to improve this script will also be appreciated!

LocalScript: Inside StarterCharacter

local plr = game.Players.LocalPlayer

wait(4)

local char = plr.Character
if plr.leaderstats.Height.Value > 1 then
	char.Humanoid.BodyHeightScale.Value = (plr.leaderstats.Height.Value / 10)
else
	char.Humanoid.BodyHeightScale.Value = 0.1
end

plr.leaderstats.Height.Changed:Connect(function()
	wait()
	char.Humanoid.BodyHeightScale.Value = (plr.leaderstats.Height.Value / 10)
end)

Thank you!

3 Likes

Well, first you should use task library (task.wait) cuz it is more accurate and faster than wait (wait is deprecated).

and instead of waiting 4 seconds, do char = plr.character or plr.characteradded:Wait(), this will see if the character exists then continue, if not then it will wait until the character exist.

and you would also need to use waitforchild on most instances, cuz they take time to load on client, failing to load any of them will error the script and will not make it work.

and instead of repeating same lines again, just put it in a function and call it when you want.

Extra:
You can use :GetPropertyChangedSignal instead of .Changed.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local height = plr:WaitForChild("leaderstats"):WaitForChild("Height")

local function Doheight()
	if height.Value > 1 then
		humanoid.BodyHeightScale.Value = height.Value / 10
	else
		humanoid.BodyHeightScale.Value = 0.1
	end
end

Doheight()

height:GetPropertyChangedSignal("Value"):Connect(Doheight)
4 Likes

It still does nothing but I don’t think it is the script (Great help btw). When I used the command bar to manually change my height it did nothing… I used same path as the script would. I don’t know if it is the method of changing the player’s height is wrong or if I need to change a setting on my game. Any ideas?

2 Likes

I did some researching and found out that you can use HeightScale property inside the HumanoidDescription
do it this way:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local height = plr:WaitForChild("leaderstats"):WaitForChild("Height")

local function Doheight()
	local Desc = humanoid:GetAppliedDescription()
	if height.Value > 1 then
		Desc.HeightScale = height.Value / 10
	else
		Desc.HeightScale = 0.1
	end
	humanoid:ApplyDescription(Desc)
end

Doheight()

height:GetPropertyChangedSignal("Value"):Connect(Doheight)
4 Likes

I got the error “Humanoid::ApplyDescription() can only be called by the backend server” what is the backend server/how can this be fixed?

4 Likes

This is because you are using a local script.

Put this server script inside StarterCharacterScripts.

local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local plr = game.Players:GetPlayerFromCharacter(char)
local height = plr:WaitForChild("leaderstats"):WaitForChild("Height")

local function Doheight()
	local Desc = humanoid:GetAppliedDescription()
	if height.Value > 1 then
		Desc.HeightScale = height.Value / 10
	else
		Desc.HeightScale = 0.1
	end
	humanoid:ApplyDescription(Desc)
end

Doheight()

height:GetPropertyChangedSignal("Value"):Connect(Doheight)
4 Likes

Making progress. Player starts out with correct height but when the height value is changed the players height does not update. Any ideas on how to fix this?

4 Likes

well, try using this:

height.Changed:Connect(Doheight)
3 Likes

still same outcome…

characters

3 Likes

Dang it.
Try this.

local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local plr = game.Players:GetPlayerFromCharacter(char)
local height = plr:WaitForChild("leaderstats"):WaitForChild("Height")

local function Doheight()
	local Desc = humanoid:GetAppliedDescription()
	if height.Value > 1 then
		Desc.HeightScale = height.Value / 10
	else
		Desc.HeightScale = 0.1
	end
	humanoid:ApplyDescription(Desc)
end

Doheight()

height:GetPropertyChangedSignal("Value"):Connect(function()
	Doheight()
end)
4 Likes

Still doesn’t work lol… Anything else that could fix it?

4 Likes

Do you know how to debug with prints?

2 Likes

oh yep lemme do that rq.
aaaaaaaa

3 Likes

Wait, would the changed event trigger if I used the command bar? It plays correctly untill I use the command bar to change my height stat, then nothing happens.

2 Likes

Wouldn’t think that work, but i didn’t try tho.
then i would think you should put it in a loop.

2 Likes

It worked when I didn’t use the command bar! Thanks for your help and bearing with me through all the issues! Many people would have given up much before this point.

2 Likes