I have a question: (Title). I tried the following, but it just destroys the ShirtTemplate and doesn't create a new one. If anyone could help, I'd appreciate it!
game.Players.PlayerAdded:connect(function(player) shirt = player.Parent:findFirstChild("Shirt") if shirt then shirt:Destroy() newshirt = Instance.new("Shirt",player) newshirt.ShirtTemplate = "http://www.roblox.com/asset/?id=116098941" end pants = player.Parent:findFirstChild("Pants") if pants then pants:Destroy() newpants = Instance.new("Pants",player) newpants.PantsTemplate = "http://www.roblox.com/asset/?id=155271561" end end)
Copy and paste id from shirts and pants + there is no need to subtract 1 from them
Why yours was wrong:
-Data hasnt loaded by the time :findFirstChild executes so your left with nil -The Parent of player is Players which isnt a character so you need to wait for chr to load by using
Example of how to fix this issue:
Player.CharacterAdded:connect(function(chr) --stuff end)
Here is your script:
local ShirtId = 153367418 local PantsId = 110454553 game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(chr) while true do shirt = chr:findFirstChild("Shirt") pants = chr:findFirstChild("Pants") if shirt and pants then break else wait() end end shirt:Destroy() pants:Destroy() local NewShirt = Instance.new("Shirt",chr) local NewPants = Instance.new("Pants",chr) NewShirt.ShirtTemplate = "http://www.roblox.com/asset/?id="..ShirtId-1 NewPants.PantsTemplate = "http://www.roblox.com/asset/?id="..PantsId-1 print("Changed "..plr.Name.."'s attire.") end) end)