I’m trying to randomize an NPC’s clothing, and it just keeps on making my NPC not have any clothes, everything else that’s apart of the script works fine, just not the clothes part. Here is my script below.
188003563,13655562,4735347390,4735346175}
local faceacc = {5355727732,5355564336,4510537113,4528880486,74970669,4507911797,4102114619,987022351,
4904398878,5063784744,4708784614}
local facial = {158066137,4995497755,987022351,5231324178,4940496302,4786863817,4524490255,5197016342}
local shirts = {15182204979,13367253189,12619102033,71471392,5455528428}
local pants = {9266897337,6028423765,5617080014,6915386269}
local marine = script.Parent.Parent.Parent
function applyAsset(id)
local item = game:GetService("InsertService"):LoadAsset(id)
local items = item:GetChildren()
local accessory = items[1]
local handle = accessory.Handle
accessory.Parent = marine
item:Destroy()
task.wait()
handle.Parent = marine
handle.Name = id
accessory:Destroy()
local weld = Instance.new("WeldConstraint")
weld.Part0 = marine.Head
weld.Part1 = handle
weld.Parent = handle
end
if script.Parent.Parent.Parent.Settings.RandomAppearance.Value then
if math.random(8) == 1 then
applyAsset(facial[math.random(#facial)])
end
if math.random(8) == 1 then
marine.Head.goggles:Destroy()
applyAsset(faceacc[math.random(#faceacc)])
end
if math.random(11) == 1 then
marine.ACH:Destroy()
applyAsset(hair[math.random(#hair)])
end
if math.random(1) == 1 then
script.Parent.Parent.Parent.Shirt.ShirtTemplate = (shirts[math.random(#shirts)])
end
if math.random(1) == 1 then
script.Parent.Parent.Parent.Pants.PantsTemplate = (pants[math.random(#pants)])
end
local skinOptions = {"Wheat","Cashmere","Beige","Light orange","Buttermilk","Pastel yellow"}
local randomSkin = BrickColor.new(skinOptions[math.random(#skinOptions)])
local bc = marine["Body Colors"]
bc.HeadColor = randomSkin
bc.LeftArmColor = randomSkin
bc.RightArmColor = randomSkin
bc.LeftLegColor = randomSkin
bc.RightLegColor = randomSkin
bc.TorsoColor = randomSkin
end