I am trying to write an auto clothing script, it gives the shirt but ignores the pants, any idea why?
local shirtid = "" --Add the ID of the shirt here
local pantsid = "" --Add the ID of the pants here
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(chr)
if plr.leaderstats2.Recruit.Value == true then
shirtid = "4925410735"
pantsid = "502705252"
end
if plr.leaderstats2.Regular.Value == true then
shirtid = "313656445"
pantsid = "502705252"
end
if plr.leaderstats2.Desert.Value == true then
shirtid = "4508458685"
pantsid = "4508459277"
end
if plr.leaderstats2.Winter.Value == true then
shirtid = "4489844052"
pantsid = "4489844773"
end
if plr.leaderstats2.PT.Value == true then
shirtid = "5553422901"
pantsid = "502705252"
end
if plr.leaderstats2.Formal.Value == true then
shirtid = "106747688"
pantsid = "106745727"
end
local shirt = chr:FindFirstChild("Shirt")
if shirt then
shirt.ShirtTemplate = "rbxassetid://" ..shirtid
else
local nshirt = Instance.new("Shirt", chr)
nshirt.Name = "Shirt"
nshirt.ShirtTemplate = "rbxassetid://" ..shirtid
end
local pants = chr:FindFirstChild("Pants")
if pants then
pants.PantsTemplate = "rbxassetid://" ..pantsid
else
local npants = Instance.new("Pants", chr)
npants.Name = "Pants"
npants.PantsTemplate = "rbxassetid://" ..pantsid
end
--If you want to remove T-Shirts, then leave this code. If not, then erase that
local tee = chr:FindFirstChild("ShirtGraphic")
if tee then
tee:Destroy()
end
end)
end)
