Hey! So yeah. I am getting way to much of these kinds of errors. Well, No errors at all but in a bad way. So basically when my player touches a brick I want it's clothes to change. I'm doing this by changing the Templates. But nothing happens, no print, no clothes change. And the thing that really gets me is there is nothing in the output. Any solutions?
script.Parent.Touched:connect(function(hit) if hit.Parent.Humanoid ~= nil then print'Failed to locate Humanoid' else hit.Parent.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=261116589" hit.Parent.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=261116467" end end)
You did do one thing wrong.
if hit.Parent.Humanoid ~= nil
Its supposed to equal right?
if hit.Parent.Humanoid == nil
script.Parent.Touched:connect(function(hit) if hit.Parent.Humanoid == nil then print'Failed to locate Humanoid' else hit.Parent.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=261116589" hit.Parent.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=261116467" end end)
Hope this helped!
You should also put a if statement checking for clothes not everyone has clothes on their character ;) so
script.Parent.Touched:connect(function(hit) if hit.Parent.Humanoid == nil then print'Failed to locate Humanoid' else if hit.Parent:FindFirstChild("Shirt") == nil then -- checks for shirts local s = Instance.new("Shirt", hit.Parent) -- creates shirt s.ShirtTemplate = "http://www.roblox.com/asset/?id=261116589" -- changes template if hit.Parent:FindFirstChild("Pants") == nil then -- checks for pants local p = Instance.new("Pants", hit.Parent) -- creates shirt p.PantsTemplate = "http://www.roblox.com/asset/?id=261116467" -- changes template else print'Player has shirt/pants' hit.Parent.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=261116589" hit.Parent.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=261116467" end end end end)
This will be a lot better