I’m trying to make a tycoon sort of game that loads npcs and puts the avatars of the players friends onto the npcs but ive ran into an issue where if the server has a bad request at getting the description ( Players:GetHumanoidDescriptionFromUserId() failed because HTTP 400 (Bad Request)) it completely stops the script from working and no further npcs are spawned.
Heres my code, thanks for any help.
while true do
for i, droppers in ipairs(droppertable) do
local randomFriend = usernames[math.random(#usernames)]
local randomFriendNPC = npc:Clone()
randomFriendNPC.PrimaryPart.Position = droppers.SpawnPoint.Position
randomFriendNPC.Parent = script.Parent.DropperFriends
local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(randomFriend)
randomFriendNPC.Humanoid:ApplyDescription(newHumanoidDescription)
end
wait(5)
end
while wait(5) do
for _, droppers in pairs(droppertable) do
local randomFriend = usernames[math.random(#usernames)]
local randomFriendNPC = npc:Clone()
randomFriendNPC.PrimaryPart.Position = droppers.SpawnPoint.Position
randomFriendNPC.Parent = script.Parent.DropperFriends
local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(randomFriend)
randomFriendNPC.Humanoid:ApplyDescription(newHumanoidDescription)
end
end
you made
in ipairs
instead of
ìn pairs
EDIT: sorry, just found out ipairs does the same thing .-.