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)
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?
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)
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)
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?
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)
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.
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.