Hello Devforum! I’m currently trying to spawn in some NPC’s that look like the players friends. When I went to go and make a script for it it errors, saying “Humanoid: :ApplyDescription() Datamodel was not available.” Since I have never worked with humanoid descriptions before Im very stumped on what to do. Just to let you know, the id that it is getting friends from is my profile id. Do you have any ideas?? Yes, the code to get friends is from the devhub
function module.Create(Position, Parent)
local function iterPageItems(pages)
return coroutine.wrap(function()
local pagenum = 1
while true do
for _, item in ipairs(pages:GetCurrentPage()) do
coroutine.yield(item, pagenum)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
pagenum = pagenum + 1
end
end)
end
local friendPages = game.Players:GetFriendsAsync(764657137)
local usernames = {}
for item, pageNo in iterPageItems(friendPages) do
table.insert(usernames, item)
end
local humDesc
local bot = game.Workspace.NPCTemplate:Clone()
local function getFriend()
local friend = usernames[math.random(1, #usernames)]
local id = friend.Id
local displayName = friend.DisplayName
print(id)
print(displayName)
return game.Players:GetHumanoidDescriptionFromUserId(id)
end
local success, errormessage = pcall(function()
humDesc = getFriend()
bot.Humanoid:ApplyDescription(humDesc, Enum.AssetTypeVerification.Always)
end)
if errormessage then
warn(errormessage)
repeat
humDesc = getFriend()
bot.Humanoid:ApplyDescription(humDesc, Enum.AssetTypeVerification.Always)
until success
end
bot.Parent = Parent
bot.HumanoidRootPart.Position = Position
end