Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to avoid GetCharacterAppearanceAsync InternalServerError?

Asked by 6 years ago
Edited 6 years ago

How do you avoid Players:GetCharacterAppearanceAsync() failed because HTTP 0 (HTTP 500 (HTTP/1.1 500 InternalServerError))

Is there a way to prevent this? I want the appearance code to run smoother

Script:

function Loader:Retry(Model)
    for _, Object in next, Model:GetChildren() do
        if Object:IsA("CharacterMesh") or Object:IsA("Shirt") or Object:IsA("Pants") or Object:IsA("Accessory") or Object:IsA("ShirtGraphic") then
            Object:Destroy()
        end
    end
    if Model.Head:findFirstChild("Mesh") then
        Model.Head.Mesh:Destroy()
    end
    UserId = math.random(1, maxuserids)
    Loader:updateModel(Model, UserId)
end

function Loader:updateModel(Model, userId)  
    local AppModel = game.Players:GetCharacterAppearanceAsync(userId)
    Model.Name = game.Players:GetNameFromUserIdAsync(userId)

    for _, Object in next, AppModel:GetChildren() do        
        if Object:IsA("SpecialMesh") or Object:IsA("BlockMesh") or Object:IsA("CylinderMesh") then          
            Object.Parent = Model.Head  
        elseif Object:IsA("Pants") or Object:IsA("ShirtGraphic") then   
            Object.Parent = Model
        elseif Object:IsA("Shirt") then 
            if Object.ShirtTemplate == "http://www.roblox.com/asset/?id=144076357" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=144076435" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=382537700" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=382538294" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=398633582" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=382538058" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=398635080" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=398634294" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=382537084" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=607785311" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=144076435" or Object.ShirtTemplate == "http://www.roblox.com/asset/?id=969769092" then
                Loader:Retry(Model)
            else 
                Object.Parent = Model
            end     
        elseif Object:IsA("Accessory") then         
            Object.Parent = Model
            Object.Handle.CFrame = Model.Head.CFrame * CFrame.new(0, Model.Head.Size.Y / 2, 0) * Object.AttachmentPoint:inverse()           
        elseif Object:IsA("Folder") then            
            if Object.Name == "R6" then
                for _, Obj in next, Object:GetChildren() do
                    if Obj:IsA("CharacterMesh") then
                        if Obj.MeshId == 82907945 or Obj.MeshId == 319346857 or Obj.MeshId == 376169183 or Obj.MeshId == 82987757 or Obj.MeshId == 303665905 or Obj.MeshId == 303665804 or Obj.MeshId == 303665872 or Obj.MeshId == 376541126 or Obj.MeshId == 279174949 or Obj.MeshId == 279174886 or Obj.MeshId == 319336109 or Obj.MeshId == 319336155 or Obj.MeshId == 82908019 or Obj.MeshId == 82907977 or Obj.MeshId == 81487640 or Obj.MeshId == 81487710 or Obj.MeshId == 83001181 or Obj.MeshId == 83001137 or Obj.MeshId == 746826007 or Obj.MeshId == 746825633 then
                            Loader:Retry(Model)
                        else
                            Obj.Parent = Model
                        end
                    end
                end
            end
        else
        end
        if not Model:FindFirstChild("Shirt") and not Model:FindFirstChild("Pants") then
            if Object:IsA("BodyColors") then
                Object.HeadColor = BrickColor.new("Mid gray")
                Object.RightArmColor = BrickColor.new("Mid gray")
                Object.LeftArmColor = BrickColor.new("Mid gray")
                Object.Parent = Model
            end
        elseif not Model:FindFirstChild("Shirt") and Model:FindFirstChild("Pants") then
            if Object:IsA("BodyColors") then
                Object.HeadColor = BrickColor.new("Mid gray")
                Object.RightArmColor = BrickColor.new("Mid gray")
                Object.LeftArmColor = BrickColor.new("Mid gray")
                Object.TorsoColor = BrickColor.new("Mid gray")
                Object.Parent = Model
            end
        end
    end

    if not Model.Head:FindFirstChild("Mesh") then       
        local m = Instance.new("SpecialMesh", Model.Head)
        m.MeshType = Enum.MeshType.Head
        m.Scale = Vector3.new(1.25, 1.25, 1.25)     
    end 
end

0
Post the script ! User#19524 175 — 6y
0
Line 3 could be shortened to: if v:IsA("CharacterAppearance") or v:IsA("Accoutrement") then User#19524 175 — 6y

Answer this question