I made a script that puts you in your normal clothes when you type "/clothes." However, the script gives me an error when I say this and turns my character nude. The error is Image failed to load Workspace.Player1.Humanoid Clothes : nil because Unexpected URL
Here is the script:
game.Workspace.ChildAdded:connect(function(char)
if char:FindFirstChild("Humanoid") then
local p = game.Players:FindFirstChild(char.Name)
if p then
if char:FindFirstChild("Shirt") then
sh = char.Shirt.ShirtTemplate
else
local d = Instance.new("Shirt")
d.Parent = char
d.Name = "Shirt"
pa = d.ShirtTemplate
end
if char:FindFirstChild("Pants") then
pa = char.Pants.PantsTemplate
else
local d = Instance.new("Pants")
d.Parent = char
d.Name = "Pants"
pa = d.PantsTemplate
end
end
end
end)
function onChatted(msg, recipient, speaker)
msg = string.lower(msg)
if (msg == "/clothes") then
speaker.Character.Pants.PantsTemplate = tostring(pa)
speaker.Character.Shirt.ShirtTemplate = tostring(sh)
end
end
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)
Please help D:

7 comments
This gives me another error; "Workspace.clothes:11: bad argument #3 to 'ShirtTemplate' (string expected, got nil)" :(
Whoops! My bad lol!
Ohhh, this script depends on pre-defined clothing IDs, but my original script was to get the individual player's clothing and THEN apply it when they said "/clothes."
Yes please, I'm not exactly sure how to do that considering I get errors every time I try.
Alright! No problem!
Inevitable, another error (sorry to bother you so much) 'Workspace.clothes:9: attempt to concatenate local 'Shirt_ID' (a nil value)' >:(
Its fixed