I am trying to create default outfit with humanoid descriptions, but I am getting this error that says: Humanoid::ApplyDescription() DataModel was not available
Here is my code located in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
local hum = player.Character and player.Character:FindFirstChild("Humanoid")
if hum then
local description = hum:GetAppliedDescription()
description.Shirt = 5929995954
description.Pants = 4945224495
hum:ApplyDescription(description)
end
end)
Solved my own problem, I added a player.CharacterAdded:Wait() and a wait(2), now it works. Here’s my changed code:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
local hum = player.Character and player.Character:FindFirstChild("Humanoid")
if hum then
print("Hum")
local description = hum:GetAppliedDescription()
description.Shirt = 5929995954
description.Pants = 4945224495
wait(2)
hum:ApplyDescription(description)
end
end)
The issue with this is that it will only work when the player joins
Try this instead, it’ll be slightly faster (won’t wait two seconds) and will work on character respawn.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local hum = character:WaitForChild("Humanoid")
if not character:IsDescendantOf(workspace) then
character.AncestryChanged:Wait()
end
local description = hum:GetAppliedDescription()
description.Shirt = 5929995954
description.Pants = 4945224495
hum:ApplyDescription(description)
end)
end)
I had the same error while trying to apply a humanoid description gotten from a player’s userId into a cloned blank rig. To solve my variant of this issue, I waited until all the base parts of the blank rig were loaded:
repeat task.wait() until (#(rig:GetChildren()) > 9)
and I had to make sure the rig was a descendant of the workspace before applying the humanoid description
Just a heads up of course, obviously you solved your situation as it seems however I wanted to share there’s also other ways I kind of do:
game:GetService("Players").PlayerAdded:Connect(function(Player : {[string] : "Player"})
Player.CharacterAdded:Connect(function(Character : {[string] : "Character"})
if not(Player:HasAppearanceLoaded() or Player.CharacterAppearanceLoaded) then
repeat task.wait() until Player:HasAppearanceLoaded() and Player.CharacterAppearanceLoaded;
end
end);
end);
This awaits until the player’s appearance has loaded, it usually works for me, but it’s pretty simple and doesn’t fully require “wait” task twice in a sort of way and etc.
It even works without the character, this is just something I’d like to addon
It’s not inherently absurd, maybe the use of repeat can be seen absurd, but it does indeed work for me when awaiting for the character to process loading, and yet no issue happens or memory usage.
But to shed some light to how it works, it detects if the player’s appearance has loaded alongside the character appearance. If one is invalid it will await in a repeat task, however it can be changed by waiting for the Character’s Appearance to load by the :Wait() function if I’m correct.
Overall, it works as any other but awaits for the player’s character to process.
I ran into this issue myself now and wanted to give a solution that feels cleaner to me than the ones above. When you call ApplyDescription on the humanoid from the CharacterAdded event, it seems to solve the issue if you simply use task.defer().
--Don't do this in CharacterAdded
Humanoid:ApplyDescription(description)
--Do this instead
task.defer(Humanoid.ApplyDescription, Humanoid, description)
This way you aren’t waiting for the next frame to call the function, while also avoiding the error.