[EDIT (8/15/21)] This thread is now outdated. Before now, there was a memory leak associated with HumanoidDescriptions. It has now been fixed and you will not have to use this method to change a player’s character appearance.
– Background
The other day, I was looking to set change a player’s character appearance, and I was pointed in the direction of HumanoidDescriptions, which is an easy way to view what a player’s character is wearing and method of changing their appearance.
– Problem
After some experimentation, and implementing HumanoidDescriptions to my game, I noticed significant spikes in server ping. The server ping got so bad that at some points, it was reaching 1000-2000ms+. At first, I figured it was just my coding, but after analyzing and rewriting anything that I might’ve thought could be the culprit, the server ping was still EXTREMELY high. My last resort was to relook at how player’s characters were being changed, as I noticed that server ping was spiking as player’s characters were being modified. Just after modifying that, server ping was back to its normal ~100-120ms, and today (after more reworking), it was hitting at max 80ms.
– Solution
My solution is as follows:
-- old code (simplified for ease of reading)
local character = player.Character
local desc = script.HumanoidDescription
character.Humanoid:ApplyDescription(desc)
-- new code (also simplified for ease of reading)
local model = script.Dummy-- a character model with a desired appearance
local animate = player.Character.Animate
plr.Character = model:Clone()
animate.Parent = player.Character
In the original code, you can see that I was using HumanoidDescriptions, as shown on the developer hub, and even with that, it was still causing enormous amounts of lag in my game. With the new code, I created a character model with the desired appearance for my players, added the original character’s Animate script to it, and then set the player’s character to that new character model.
I couldn’t find any other resources on how to properly set a player’s appearance, and I still see people recommending HumanoidDescriptions to others.
SOME OTHER NOTES:
- Server ping remained high, even after the characters that had HumanoidDescriptions applied were destroyed.
- Animations broke frequently when using HumanoidDescriptions.
- As HumanoidDescriptions were being applied, the server ping was hitting its peak.
I would’ve liked to post this in #bug-reports , as I see this as a larger issue. The developer hub doesn’t make any note of dropped performance when using HumanoidDescriptions at all, and after searching on this forum, I noticed that I wasn’t the only one experiencing this issue.