local S=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local I=S:WaitForChild("\099\111\109\109\111\110")local z=S:WaitForChild("\097\115\115\101\116\109\111\100\101\108\115")local f=require(I:WaitForChild("\065\115\115\101\116\115"))local p={hat=function(S,I)local f=(z:WaitForChild("\104\097\116\115")):FindFirstChild(S)if not f then warn("\104\097\116\109\111\100\101\108 "..(S.." \100\111\101\115 \110\111\116 \101\120\105\115\116"))return(z:WaitForChild("\101\114\114\111\114")):Clone()end return((z:WaitForChild("\104\097\116\115")):FindFirstChild(S)):Clone()end;face=function(S,I)local f=(z:WaitForChild("\109\097\116\101\114\105\097\108\115")).materialbase:Clone()f.Decal.Texture=I.metadata.image or"\114\098\120\097\115\115\101\116\105\100\058\047\047\049\048\050\051\049\050\051\048\049"return f end;material=function(S,I)local f=(z:WaitForChild("\109\097\116\101\114\105\097\108\115")).materialbase:Clone()f.Color=I.metadata.color or(BrickColor.new("\087\104\105\116\101")).Color f.Material=I.metadata.material or Enum.Material.Plastic f.Reflectance=I.metadata.reflectance or 0 f.Transparency=I.metadata.transparency or 0 return f end;pet=function(S,I)return((z:WaitForChild("\112\101\116\115")):FindFirstChild(S)):Clone()end,effect=function(S,I)return(z:WaitForChild("\109\097\116\101\114\105\097\108\115")).materialbase:Clone()end}return function(S)local I=f.byId[S]assert(I,"\073\110\118\097\108\105\100 \097\115\115\101\116 \105\100\044 \099\097\110\110\111\116 \112\114\111\100\117\099\101 \109\111\100\101\108")local z=I.type assert(z,"\065\115\115\101\116 \109\117\115\116 \104\097\118\101 \097 \116\121\112\101 \116\111 \112\114\111\100\117\099\101 \109\111\100\101\108\044 \103\111\116 \110\105\108")assert(p[z],"\077\111\100\101\108 \114\101\110\100\101\114\105\110\103 \102\111\114 \116\104\105\115 \116\121\112\101 \110\111\116 \105\109\112\108\101\109\101\110\116\101\100 \121\101\116\046 \058\040")return p[z](S,I)end
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local common = ReplicatedStorage:WaitForChild("common")
local models = ReplicatedStorage:WaitForChild("assetmodels")

local Assets = require(common:WaitForChild("Assets"))

local cataFuncs = {
    hat = function(id, asset)
        local hatModel = models:WaitForChild("hats"):FindFirstChild(id)
        if not hatModel then 
            warn("hatmodel "..id.." does not exist")
            return models:WaitForChild("error"):Clone()
        end
        return models:WaitForChild("hats"):FindFirstChild(id):Clone()
    end,
    face = function(id, asset)
        local egbase = models:WaitForChild("materials").materialbase:Clone()

        egbase.Decal.Texture = asset.metadata.image or "rbxassetid://102312301"

        return egbase
    end,
    material = function(id, asset)
        local materialSample = models:WaitForChild("materials").materialbase:Clone()

        materialSample.Color = asset.metadata.color or BrickColor.new("White").Color
        materialSample.Material = asset.metadata.material or Enum.Material.Plastic
        materialSample.Reflectance = asset.metadata.reflectance or 0
        materialSample.Transparency = asset.metadata.transparency or 0

        return materialSample
    end,
    pet = function(id, asset)
        return models:WaitForChild("pets"):FindFirstChild(id):Clone()
    end,
    effect = function(id,asset)
        return models:WaitForChild("materials").materialbase:Clone()
    end
}

return function(id)
    local asset = Assets.byId[id]
    assert(asset, "Invalid asset id, cannot produce model")
    local type = asset.type
    assert(type, "Asset must have a type to produce model, got nil")
    assert(cataFuncs[type], "Model rendering for this type not implemented yet. :(")
    return cataFuncs[type](id,asset)
end