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:
Quite a simple mistake. But, instead of making another let's fix the entire code shall we?
Its fixed. Just so I have proof. http://i.imgur.com/LLq6A6L.gif
local Players =game.Players local Prefix="http://www.roblox.com/asset/?id=" function GetSplit(msg) local a = nil for i = 1,#msg do if msg:sub(i,i) == "," then a = i+1 break end end if a ~= nil then return {msg:sub(10,a-2), msg:sub(a)} else return nil end end function Change(char, shirt, pant) if char:FindFirstChild("Humanoid") then local Player = game.Players:GetPlayerFromCharacter(char) if char:FindFirstChild("Shirt",true) then char.Shirt.ShirtTemplate = Prefix..shirt else local Shirt = Instance.new("Shirt", char) Shirt.ShirtTemplate = Prefix..shirt end if char:FindFirstChild("Pants",true) then char.Pants.PantsTemplate = Prefix..pant else local Pants = Instance.new("Pants", char) Pants.PantsTemplate = Prefix..pant end end end Players.PlayerAdded:connect(function(Player) Player.Chatted:connect(function(Message) if Message:lower():sub(1,3) == "/e " then -- /e fix Message = Message:sub(4) end if Message:lower():sub(1,8) == "/clothes" then local Table = GetSplit(Message) local Shirt,Pants = Table[1],Table[2] if type(Table) == "table" then Change(Player.Character, Shirt, Pants) -- So I chatted /clothes 432070756,417042178 and it worked fine else warn("Error occured") end end end) end)