Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't my Player change cloths?

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)

2 answers

✓ Accepted answer

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!

2 comments

0

Yes! Thank you! Once again, silly me missing the easiest of details! Thanks again!

0

No problem, happens to even the bests :)!

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

This discussion is preserved as it was. New answers, comments, and votes are closed.