Team Body Colors, face and clothes

I’m working on a game and i need help with a script that changes the player’s face, body colors and clothes depending on the team he’s on

I’m a begginer scripter so i can’t write complicated scripts so everything i tried so far hasn’t worked (I’ve tried changing clothing-changing scripts and it didn’t worked, i didn’t found any tutorials so far that helped me and i have tried to make a script on my own but as i mentioned i am a begginer so THAT didn’t worked at all)

I really need this script to work or i won’t be able to fisht my game (Since in that game i have a round system that randomally changes the player’s team to “Human” or “Shadow Being” and i need that the shadow being have a specific clothing, face and body color

I really ask that if somebody wants to help me, that you try to explain the script as as i have writen, i am a begginer and i don’t undertand much about scripts

3 Likes

You can parent a Highlight instance to the player’s character and change its fill color whenever the player’s team changes.

You could store your skins in a Folder inside the Replicated Storage then code something like this in your Rounds handler script.

local PlayerService = game:GetService("Players")
local TeamService = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local SkinsFolder = ReplicatedStorage:WaitForChild("SkinsFolder" ,30)

for i, Players in pairs(PlayerService:GetChildren())do
	if SkinsFolder and Players.Team == TeamService.Human then
		local Character = workspace:FindFirstChild(Players.Name)
		local Head = Character and Character:FindFirstChild("Head")
		
		local HumanClothes = SkinsFolder:FindFirstChild("HumanClothes")
		local HumanFace = SkinsFolder:FindFirstChild("HumanFace")
		local HumanColor = SkinsFolder:FindFirstChild("HumanColor")
		
		if Character and Head and HumanClothes and HumanFace and HumanColor then
			for i,v in pairs(Character:GetDescendants())do
				if v:IsA("BodyColors")or v:IsA("Shirt")or v:IsA("Pant")or (v:IsA("Decal")and v.Parent.Name == "Head")then
					v:Destroy()
				end
			end
			HumanClothes:Clone().Parent = Character
			HumanFace:Clone().Parent = Head
			HumanColor:Clone().Parent = Character
		end
	elseif SkinsFolder and Players.Team == TeamService.Shadow then
		--Same
	end
end

So, i create a folder on replicated storage with the decal, body colors and clothing? An if so, do i make this a separate script or do i just make this on the round script?

Okay, i tried my best to make it understandable for a new scripter, if you have ANY questions just ask me

First thing you need to do is create 3 StringValues in each team called “Face”, “Shirt” and “Pants”, each one with the decal/shirt/pants url that you want a team to have,

then in a script copy paste this into it. script should be in serverscriptservice

-- // Script Made by DARKMASTER6906 // --

--// Services
local Players = game:GetService("Players")
local TM = game:GetService("Teams")

--// Tables
local conn = {} --this should prevent memory leaks
local BlacklistedParts = { --list of bodyparts that will not be colored
	
	"Head",
	"Torso",
	"LeftLeg"
	
}

--// Functions
local function playerAdded(Player)
	conn[Player] = {}
	
	conn[Player][#conn[Player] + 1] = Player.CharacterAdded:Connect(function(Char)
		repeat wait() until Char:FindFirstChild("Humanoid") and Char:FindFirstChild("Body Colors")
		
		local Team = Player.Team
		local TeamColor = Team.TeamColor
		local BodyColors = Char:FindFirstChild("Body Colors")
		local Shirt = Char:FindFirstChild("Shirt")
		local Pants = Char:FindFirstChild("Pants")
		local Face = Char.Head:FindFirstChild("face")
		
		--// Color changing
		for i, part in pairs(Char:GetChildren()) do
			if part:IsA("BasePart") and not table.find(BlacklistedParts, part.Name) then
				part.BrickColor = TeamColor
			end
		end
		
		--// Because Roblox has a BodyColors thing in each player, we need to set that too
		--// Remove what parts dont need coloring and keep what does
		BodyColors.HeadColor = TeamColor
		BodyColors.LeftArmColor = TeamColor
		BodyColors.LeftLegColor = TeamColor
		BodyColors.RightArmColor = TeamColor
		BodyColors.RightLegColor = TeamColor
		BodyColors.TorsoColor = TeamColor
		
		--// Clothes changing
		Shirt.ShirtTemplate = Team.Shirt
		Pants.PantsTemplate = Team.Pants
		
		--// Face changing
		Face.Texture = Team.Decal
	end)
end

--// Gets every team
for i, team in pairs(TM:GetChildren()) do
	team.PlayerAdded:Connect(playerAdded)
end

--// This disconnects that character function when the player leaves the game
Players.PlayerRemoving:Connect(function(Player)
	for i, connect in pairs(conn[Player]) do
		connect:Disconnect()
		conn[Player][i] = nil
		if #conn[Player] <= 0 then
			conn[Player] = nil
		end
	end
end)

Ok, thanks for your help first of all, i could understand most of the script but it had a few problems

Well, in my game there are 3 teams so your script makes my character white when he is on the lobby team

That was the issue that the script is trying to search for a shirt, pant or face value on the lobby team which makes the script break, if you could help me correct those problems or correct the script since now you have more context.

as i said i really apreciate your help i am willian to even have you listed in the credits if this works as i am really needing some help here

if i understand the issue right, the lobby team shouldnt be getting colored, etc
so we will make another blacklist for that and with a table.find if statement, we can check if the team is in that blacklist

if you want to turn the blacklist into a whitelist then just make the if table.find(BlacklistedTeams, Team) then return else line a if not table.find(BlacklistedTeams, Team) then return else instead

-- // Script Made by DARKMASTER6906 // --

--// Services
local Players = game:GetService("Players")
local TM = game:GetService("Teams")

--// Tables
local conn = {} --this should prevent memory leaks
local BlacklistedTeams = { --teams that will not be affected by the script
	
	"Lobby"
	
}

--// Functions
local function playerAdded(Player)
	conn[Player] = {}
	
	conn[Player][#conn[Player] + 1] = Player.CharacterAdded:Connect(function(Char)
		repeat wait() until Char:FindFirstChild("Humanoid") and Char:FindFirstChild("Body Colors")
		
		local Team = Player.Team
		local TeamColor = Team.TeamColor
		if table.find(BlacklistedTeams, Team) then return else --this will block teams in the blacklist from progressing in the script

			local BodyColors = Char:FindFirstChild("Body Colors")
			local Shirt = Char:FindFirstChild("Shirt")
			local Pants = Char:FindFirstChild("Pants")
			local Face = Char.Head:FindFirstChild("face")
			
			--// Color changing
			for i, part in pairs(Char:GetChildren()) do
				if part:IsA("BasePart") and not table.find(BlacklistedParts, part.Name) then
					part.BrickColor = TeamColor
				end
			end
		
			--// Because Roblox has a BodyColors thing in each player, we need to set that too
			--// Remove what parts dont need coloring and keep what does
			BodyColors.HeadColor = TeamColor
			BodyColors.LeftArmColor = TeamColor
			BodyColors.LeftLegColor = TeamColor
			BodyColors.RightArmColor = TeamColor
			BodyColors.RightLegColor = TeamColor
			BodyColors.TorsoColor = TeamColor
		
			--// Clothes changing
			Shirt.ShirtTemplate = Team.Shirt
			Pants.PantsTemplate = Team.Pants
		
			--// Face changing
			Face.Texture = Team.Decal
		end
	end)
end

--// Gets every team
for i, team in pairs(TM:GetChildren()) do
	team.PlayerAdded:Connect(playerAdded)
end

--// This disconnects that character function when the player leaves the game
Players.PlayerRemoving:Connect(function(Player)
	for i, connect in pairs(conn[Player]) do
		connect:Disconnect()
		conn[Player][i] = nil
		if #conn[Player] <= 0 then
			conn[Player] = nil
		end
	end
end)