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

Why this team color clothing script don't work ?

Asked by
Bulvyte 388 Moderation Voter
8 years ago

So what this script is when player joins game and checks its team it should give him shirt and pants of the team's color but it does not and if he changes teams it should give clothes on the teams color..

game.Players.PlayerAdded:connect(function(Plr)
Plr.CharacterAdded:connect(function(Char)
for i,v in pairs(Char:GetChildren()) do
if v.ClassName == "Shirt" or v.ClassName == "Pants" then
v:Destroy()
end
end
if Plr.TeamColor == BrickColor.new("Brick yellow") then
x = Instance.new("Shirt",Char)
x.ShirtTemplate = "132601095"
else
x = Instance.new("Shirt",Char)
x.ShirtTemplate = "132601106"
end
end)
end)

whats the prob ?

1 answer

Log in to vote
0
Answered by 8 years ago

The issue is that you are trying to set ShirtTemplateto the ID of the clothing. You need to set it to the address of the content:

game.Players.PlayerAdded:connect(function(Plr)
    Plr.CharacterAdded:connect(function(Char)
        for i,v in pairs(Char:GetChildren()) do
            if v:IsA("Clothing") then -- Here, rather than checking if it's a Shirt or Pants, I check if it inherits from Clothing.
                v:Destroy()
            end
        end
        if Plr.TeamColor == BrickColor.new("Brick yellow") then
            local x = Instance.new("Shirt",Char)
            x.ShirtTemplate = "http://www.roblox.com/asset/?id=132601094"
        else
            local x = Instance.new("Shirt",Char)
            x.ShirtTemplate = "http://www.roblox.com/asset/?id=132601105"
        end
    end)
end)

I also noticed you used the ID of the shirt item, rather than the shirt image. I corrected that for you in the script above. Additionally, I indented the code, which is good practice.

0
How do i even test it ? Since Players in studio are without clothes Bulvyte 388 — 8y
0
The test in studio does give players clothes; you could also try publishing the game and trying online. IDidMakeThat 1135 — 8y
Ad

Answer this question