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

Why this team color clothing script don't work ?

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

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.

2 comments

0

How do i even test it ? Since Players in studio are without clothes

0

The test in studio does give players clothes; you could also try publishing the game and trying online.

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