I need help on my new script. The help i need is that i want it so that the person presses a button using gui's and then the shirt and pants appear on the human.
--Made by codboy22
local shirtTemplate = "http://www.roblox.com/asset/?id=59323775"
local pantsTemplate = "http://www.roblox.com/asset/?id=59404936"
-------------------------------------------------------
local faceID = ""
-------------------------------------------------------
local delete_Tshirts = true
-------------------------------------------------------
-- Main coding:
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
game.Players.PlayerAdded:connect(function(p)
repeat wait() until p.Character -- Wait for the new player to spawn
changeClothing(p)
p.Changed:connect(function(x)
if (x == "Character") then
game:service("RunService").Stepped:wait()
if not (p.Character) then return end
changeClothing(p)
end
end)
end)
script.Parent.MouseButton1Down:connect(onClicked)

1 comment
Parenting the shirt/pants to the character model seems correct, if that's what you mean. Your question is quite unclear, sorry. Are there any errors? Are the clothes not what it's supposed to look like? What happened?