I have a script that randomly picks clothes, pants, faces, and hats for a character, however it keeps randomly giving me this error. It usually works, but it just breaks and shows this error like 10% of the time for some reason. I looked at every single ID and I dont see any duplicates.
Here is my code:
local policeclothing = {}
local Workspace = game:GetService("Workspace")
local Catalog = {
shirts = {
169452027
},
pants = {
2430769797
},
faces = {
141728790,
7074729,
9250660,
7076076,
7131886,
66330265,
823012694,
150182378,
406001308,
1016186364,
7074991,
7074814,
7075502,
7131541,
9250654,
7074661,
14861743,
110288809 --beard
},
hair = {
32278814,
13477818,
3814450142,
417457139,
2606178351,
19327469,
77799954,
3814456274,
80921949,
1180422807,
343584973,
62719569,
62692030,
83013160,
12270248,
24939213,
161246558,
62234425,
9244070571,
6467597842,
11452955059
}
}
local function RandomizeAppearance(npc)
-- Get random ids
local randomShirtId = Catalog.shirts[math.random(1, #Catalog.shirts)]
local randomPantsId = Catalog.pants[math.random(1, #Catalog.pants)]
local randomFaceId = Catalog.faces[math.random(1, #Catalog.faces)]
local randomHairId = Catalog.hair[math.random(1, #Catalog.hair)]
local skinColor = Color3.fromRGB(204, 142, 105)
local humanoidDescription = Instance.new("HumanoidDescription")
-- Apply premade skin color
humanoidDescription.HeadColor = skinColor
humanoidDescription.LeftArmColor = skinColor
humanoidDescription.RightArmColor = skinColor
humanoidDescription.LeftLegColor = skinColor
humanoidDescription.RightLegColor = skinColor
humanoidDescription.TorsoColor = skinColor
-- Apply random clothing and a face
humanoidDescription.Shirt = randomShirtId
humanoidDescription.Pants = randomPantsId
humanoidDescription.Face = randomFaceId
humanoidDescription.HatAccessory = randomHairId
-- Apply the appearance to the humanoid
npc:WaitForChild("Humanoid"):ApplyDescription(humanoidDescription)
-- Discard the instance as we will longer need it
humanoidDescription:Destroy()
end
function policeclothing.pickRandom(char)
RandomizeAppearance(char)
end
return policeclothing
Thanks in advance.