Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
4

Why won't my Player change cloths?

Asked by 8 years ago

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

Log in to vote
1
Answered by
iNicklas 215 Moderation Voter
8 years ago

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!

0
Yes! Thank you! Once again, silly me missing the easiest of details! Thanks again! minikitkat 687 — 8y
0
No problem, happens to even the bests :)! iNicklas 215 — 8y
Ad
Log in to vote
0
Answered by
Prioxis 673 Moderation Voter
8 years ago

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

Answer this question