I made a script inside of a tool that is supposed to say when I click mouse button 1, equip these assets onto the character. However it doens't work and I don't know why. Can I get some help?
Here is my code
local shirtTemplate = "http://www.roblox.com/asset/?id=375845776"
local pantsTemplate = "http://www.roblox.com/asset/?id=375845821"
local faceID = "http://www.roblox.com/asset/?id=19398553"
local delete_Tshirts = true
script.Parent.Mousebutton1click:connect(function()
function changeClothing(p)
if (p.Character) then
local shirt = true
local pants = true
local face = true
if (shirtTemplate == "") then shirt = false end
if (pantsTemplate == "") then pants = false end
if (faceID == "") then face = false end
local S = Instance.new("Shirt")
S.Name = "Shirt"
S.ShirtTemplate = shirtTemplate
local P = Instance.new("Pants")
P.Name = "Pants"
P.PantsTemplate = pantsTemplate
for _,v in pairs(p.Character:GetChildren()) do
if (v.className == "Shirt") then
if (shirt) then
v:remove()
end
elseif (v.className == "Pants") then
if (pants) then
v:remove()
end
elseif ((v.className == "Part") and (v.Name == "Torso")) then
if ((delete_Tshirts) and (v:findFirstChild("roblox"))) then
v.roblox:remove()
end
elseif ((v.className == "Part") and (v.Name == "Head")) then
if ((face) and (v:findFirstChild("face"))) then
v.face.Texture = faceID
end
end
if (shirt) then
S.Parent = p.Character
end
if (pants) then
P.Parent = p.Character
end
end
print("Changed " .. p.Name .. "'s clothing")
else
print(p.Name .. "'s character was not found; function returned")
return
end
end
end)

2 comments
it does not work because you use deprecated stuff
You used "function()" twice.