Changing Clolor for teams

Ok, so, This sone should be easy, but Im dumb

I want the players torso, humanoid root part, and legs to correspond to the color to the team theyre on

help

Thanks for reading

I think I can manage scripting it myself if you put it simply

You could just get the player, find there time by the .Team from the properties and then once you have the team you can simply get the colour via Team.TeamColor and then you just find the body parts and change the colour.

game.Players.PlayerAdded:Connect(function(plr)
	local MyTeamColor = plr.TeamColor
	plr.CharacterAdded:Connect(function(char)	
		wait(1)
		while wait(0.5) do
			local MyTeamColor = plr.TeamColor     
		char.Torso.BrickColor = MyTeamColor
			char.RightLeg.BrickColor = MyTeamColor
			char.LeftLeg.BrickColor = MyTeamColor
			char.HumanoidRootPart.BrickColor = MyTeamColor
			end
	end)
end)

--HowsThis?

EDIT, it only changes the torso color

Why are you using a while true loop?


game.Players.PlayerAdded:Connect(function(Plr)
	Plr:GetPropertyChangedSignal("TeamColor"):Connect(function(Color)
		if Plr.Character then
			for i,v in pairs(Plr.Character:GetChildren()) do
				if v:IsA("BasePart") then
					v.BrickColor = Color
				end
			end
		end
	end)
	Plr.CharacterAdded:Connect(function()
		for i,v in pairs(Plr.Character:GetChildren()) do
			if v:IsA("BasePart") then
				v.BrickColor = Plr.TeamColor
			end
		end
	end)
end)

Idk, I just do what I can do, it might be wrong, but, yeah

Use my script lol it works, and it even will change it when the team color updates

1 Like

ok, im trying it rn
darncharslol

W̶o̶u̶l̶d̶ ̶t̶h̶e̶r̶e̶ ̶n̶o̶t̶ ̶b̶e̶ ̶a̶n̶ ̶i̶s̶s̶u̶e̶ ̶w̶i̶t̶h̶ ̶y̶o̶u̶r̶ ̶c̶o̶d̶e̶ ̶c̶u̶z̶ ̶m̶o̶s̶t̶ ̶o̶f̶ ̶t̶h̶e̶ ̶p̶a̶r̶t̶s̶ ̶o̶n̶ ̶t̶h̶e̶ ̶c̶h̶a̶r̶a̶c̶t̶e̶r̶ ̶a̶r̶e̶ ̶m̶e̶s̶h̶P̶a̶r̶t̶s̶

Ignore me. I mixed up part and basePart.

BasePart also equals meshparts

1 Like

Yea my bad. I was mixing up part and basePart

I used a team changer and its the same

Since it works would you mind marking my comment as the solution! Thanks!

just a question, how can I make it so only the legs and the torso and the humanoid rPart are changed

instead of a for loop just to

Plr.Character.UpperTorso.BodyColor = TeamColor
Plr.Character.LowerTorso.BodyColor = TeamColor
Plr.Character.LeftFoot.BodyColor = TeamColor
Plr.Character.RightFoot.BodyColor = TeamColor
Plr.Character.LeftLowerLeg.BodyColor = TeamColor
Plr.Character.RightLowerLeg.BodyColor = TeamColor
Plr.Character.LeftUpperLeg.BodyColor = TeamColor
Plr.Character.RightUpperLeg.BodyColor = TeamColor

1 Like

You would just check if the part is one of the things you want to check or do what @KowalskiStan which would be more efficient cuz you don’t really need to loop through them all if its only 1 - 2.

Replace my for loops with this one

for i,v in pairs(Plr.Character:GetChildren()) do
	if v:IsA("BasePart") and v.Name:find("Leg") or v.Name:find("Torso") then
		v.BrickColor = Plr.TeamColor
	end
end