How to give players skin-colors based on their team

  1. What do you want to achieve? I want players to have a specific skin color depending on what teams they are in.

  2. What is the issue? I could not find a solution on how to.

  3. What solutions have you tried so far?

I tried to make a script but I don’t know what to do next:

local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

game.Players.PlayerAdded:Connect(function(player)

	if player.Team == Teams["TeamA"] then
		--code
	end
end)

My goal is to replicate a feature from PMEBGE, by Mr_Wiggles, (Note: I only want to replicate this feature and nothing else. The gameplay, items, and everything else on my game would be not replicated from PMEBGE) in which the teams in the game have color-coded skin based on their team as seen below (the peasant team has brown-colored torso and the admission team has blue):

3 Likes

well i believe if you wanna change there body color there is an option but first you’ll have to get the player on that team go inside its character locate the bodycolor and change it

Either change their BodyColors, their HumanoidDescription or change their body parts directly.

HumanoidDescription:

local HumDesc = character:FindFirstChild("Humanoid") and character.Humanoid:FindFirstChildWhichIsA("HumanoidDescription")
if HumDesc then
   -- These are Color3 values
   HumDesc.HeadColor = HumDesc.HeadColor
   HumDesc.LeftArmColor = HumDesc.LeftArmColor
   HumDesc.LeftLegColor = HumDesc.LeftLegColor
   HumDesc.RightArmColor = HumDesc.RightArmColor
   HumDesc.RightLegColor = HumDesc.RightLegColor
   HumDesc.TorsoColor = HumDesc.TorsoColor
   --character.Humanoid:ApplyDescription(HumDesc) -- Unsure if you do or do not need this.
end

BodyColors:

local BodyColor = character:FindFirstChildWhichIsA("BodyColors")

if BodyColors then
   -- These are Color3 values, if you want a BrickColor value remove the 3s after.
   BodyColors.HeadColor3
   BodyColors.LeftArmColor3
   BodyColors.LeftLegColor3
   BodyColors.RightArmColor3
   BodyColors.RightLegColor3
   BodyColors.TorsoColor3
end
for bodyPartName, propertyValue in pairs({["Head"] = Color3.new(0, 1, 0)} do
   if character:FindFirstChild(bodyPartName) then
      character[bodyPartName] = propertyValue
   end
end

To get the team color use, note that this is the brick color value

local player -- variable for the player
local TeamColor = player.TeamColor -- or (player.Team and player.Team.TeamColor) would work as well

To turn the brick color into Color3 use:

local TeamColor3 = TeamColor.Color -- this will return the Color3 value.
1 Like

you can get Teamcolor and then utilize the information you get from Teamcolor in a Color3.

Keep in mind that the brick colors will not work with .fromrgb so use .new instead

example code:

local plrT = plr.TeamColor --Gets the player team color

local character = plr.Character

local head = character:WaitForChild("Head") --input whatever body part you are using here


head.Color = Color3.new(plrT.r, plrT.g, plrT.b) 
1 Like
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(character)
		local shirt = character:FindFirstChildOfClass("Shirt")
		if shirt then
			shirt:Destroy()
		end

		local pants = character:FindFirstChildOfClass("Pants")
		if pants then
			pants:Destroy()
		end

		local shirtGraphic = character:FindFirstChildOfClass("ShirtGraphic")
		if shirtGraphic then
			shirtGraphic:Destroy()
		end

		local humanoid = character:WaitForChild("Humanoid")
		if humanoid.RigType == Enum.HumanoidRigType.R6 then
			for _, child in ipairs(character:GetChildren()) do
				if child:IsA("BasePart") then
					if child.Name == "Torso" then
						child.Color = player.Team.TeamColor.Color
					elseif child.Name == "Head" or child.Name == "Left Arm" or child.Name == "Right Arm" then
						child.Color = Color3.fromRGB(245, 205, 48)
					elseif child.Name == "Left Leg" or child.Name == "Right Leg" then
						child.Color = Color3.fromRGB(164, 189, 71)
					end
				elseif child:IsA("CharacterMesh") then
					child:Destroy()
				end
			end
		elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
			local bodyColors = character:FindFirstChildOfClass("BodyColors")
			bodyColors:Destroy()
			for _, child in ipairs(character:GetChildren()) do
				if child:IsA("BasePart") then
					if child.Name == "UpperTorso" or child.Name == "LowerTorso" then
						child.Color = player.Team.TeamColor.Color
					elseif child.Name == "Head" or child.Name == "LeftUpperArm" or child.Name == "LeftLowerArm" or child.Name == "LeftHand" or child.Name == "RightUpperArm" or child.Name == "RightLowerArm" or child.Name == "RightHand" then
						child.Color = Color3.fromRGB(245, 205, 48)
					elseif child.Name == "LeftUpperLeg" or child.Name == "LeftLowerLeg" or child.Name == "LeftFoot" or child.Name == "RightUpperLeg" or child.Name == "RightLowerLeg" or child.Name == "RightFoot" then
						child.Color = Color3.fromRGB(164, 189, 71)
					end
				end
			end
		end
	end)
end)

I believe this is what you’re looking for, the script is compatible with both R6 and R15 avatar types.
The standard “noob” colors are applied (as shown in the provided screenshot) and the torso is colored to match the player’s team’s color. Additionally, any clothing worn by the player’s character is removed.

9 Likes

Yes, this is what I am looking. I apologize for not being clearer and thank you and others for putting time into this. Everything is fine in your script except that it doesn’t work for R6 avatars, the skin colors are not changing.

well check the name of the parts in the r6 character

For some reason destroying “Body Colors” when the avatar is R6 results in the avatar not being colored correctly, I’ve edited the original post and fixed that issue.

image

1 Like

Great, but what would you put this script under? And also, would it be a Script or a LocalScript?

2 Likes