I have a script that grants players random heights and when they leave their height saves and it loads their saved height when they join. This script works, however, the humanoid’s height doesn’t always change. If I print currentHeight it shows the correct height but it doesn’t change the player height consistently, it only works sometimes. Help would be appreciated!
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
local thing = heights[heighttable[math.random(#heighttable)]]
local human = char:WaitForChild("Humanoid")
local plrKey = "id_"..plr.UserId
local GetSaved = saveData:GetAsync(plrKey)
if GetSaved ~= nil then
currentHeight = GetSaved[1]
heightString = GetSaved[2]
warn("Player has data!")
else
currentHeight = thing[1]
heightString = thing[2]
local numForSaving = {currentHeight, heightString}
saveData:GetAsync(plrKey, numForSaving)
warn("Player has no data!")
end
human:WaitForChild("BodyHeightScale").Value = currentHeight
plr.PlayerGui:WaitForChild("Stats").Foundation.HeightLabel.Text = "Height: "..heightString
print(currentHeight) -- works but sometimes fails to set the BodyHeightScale to the currentHeight value.
if currentHeight >= 1.45 then currentHeight = 1.45 end
end
end)