Team Color Won't Change

Hello developers! I am working on a script that makes a new team whenever me or the founder join the game. Everything works right, except for the color. For some reason, it will not set the team color. The color I am trying to set it to is toothpaste. I have no errors at all. Any help is appreciated. Thanks!

Script:

-- Caden
local minigun = game.ServerStorage:WaitForChild("Minigun")

game.Players.PlayerAdded:Connect(function(player)
	if game.Teams:FindFirstChild("Founder") == nil then
		if player.UserId == 221567745 or 286092004 then
			local founderTeam = Instance.new("Team")
			founderTeam.Parent = game.Teams
			minigun:Clone().Parent = founderTeam
			founderTeam.Name = "Founder"
			founderTeam.AutoAssignable = true
			founderTeam.TeamColor = BrickColor.new(85, 255, 255)
			player.Team = founderTeam
		end
	else
		if player.UserId == 221567745 or 286092004 then
			player.Team = game.Teams.Founder
		end
	end
end)

It’s because you are assigning the player’s team to an object, which is a team instance/object. You are supposed to give it a color. So you should use the TeamColor property instead.

local minigun = game.ServerStorage:WaitForChild("Minigun")

game.Players.PlayerAdded:Connect(function(player)
	if game.Teams:FindFirstChild("Founder") == nil then
		if player.UserId == 221567745 or 286092004 then
			local founderTeam = Instance.new("Team")
			founderTeam.Parent = game.Teams
			minigun:Clone().Parent = founderTeam
			founderTeam.Name = "Founder"
			founderTeam.AutoAssignable = true
			founderTeam.TeamColor = BrickColor.new(85, 255, 255)
			player.Team = founderTeam.TeamColor
		end
	else
		if player.UserId == 221567745 or 286092004 then
			player.Team = game.Teams.Founder.TeamColor
		end
	end
end)
local minigun = game.ServerStorage:WaitForChild("Minigun")

game.Players.PlayerAdded:Connect(function(player)
	if not game.Teams:FindFirstChild("Founder") then
		if player.UserId == 221567745 or player.UserId == 286092004 then
			local founderTeam = Instance.new("Team")
			founderTeam.Parent = game.Teams
			minigun:Clone().Parent = founderTeam
			founderTeam.Name = "Founder"
			founderTeam.AutoAssignable = true
			founderTeam.TeamColor = BrickColor.new("Really black")
			player.Team = founderTeam
		end
	else
		if player.UserId == 221567745 or player.UserId == 286092004 then
			player.Team = game.Teams.Founder
		end
	end
end)

The conditional statement was incorrect and would always evaluate as true, you always need to respecify what is being checked against when splitting conditional statements into multiple parts through use of the various Boolean logic operators (and, or etc.).

if player.UserId == 221567745 or player.UserId == 286092004 then

You also used an invalid BrickColor value, I’ve used a valid one below.

founderTeam.TeamColor = BrickColor.new("Really black")
1 Like

https://developer.roblox.com/en-us/api-reference/property/Player/TeamColor

It’s often a better idea to set Player.Team to the respective Team instead of using this property. Setting this property often leads to repetition of the same BrickColor value for a certain teams across many scripts; this is something you want to avoid when adhering to the don’t-repeat-yourself principle.