Having Problems with Changing Teams

Hello.

I am currently writing this tired as ever, but still coding away. I’m having trouble with a team GUI switch. It’s meant to work that there is a lobby team (the color is fossil) and you can switch to either blue or red. Originally it could only switch between blue and the spectator team, so I tried fixing that. But now no teams switch at all. It’s probably an easy fix that my sleep deprivated mind couldn’t figure out, but if anybody got help, please send it through.

LocalScript inside of TextButton.

local remoteEvent = game.ReplicatedStorage.Team
local blue = "Bright blue"
local red = "Bright red"
local fossil = "Fossil"

local lolplayer = game.Players.LocalPlayer
local val = Instance.new("BoolValue")
val.Name = "inout"
val.Parent = lolplayer

local blueTeam = #game.Teams.Blue:GetPlayers()
local redTeam = #game.Teams.Red:GetPlayers()
local noSwitch = false

print(lolplayer.TeamColor)

script.Parent.MouseButton1Click:Connect(function()
	if lolplayer.TeamColor == blue or lolplayer.TeamColor == red then
		remoteEvent:FireServer(BrickColor.new(fossil))
	elseif blueTeam < redTeam or blueTeam == redTeam and lolplayer.TeamColor == fossil then
		remoteEvent:FireServer(BrickColor.new(blue))
	elseif blueTeam > redTeam and lolplayer.TeamColor == fossil then
		remoteEvent:FireServer(BrickColor.new(red))
	end
end)

Remote Event Fire

game.ReplicatedStorage.Team.OnServerEvent:Connect(function(player, teamColor)
	player.TeamColor = teamColor
	player:LoadCharacter()
	player.leaderstats.Deaths.Value = 0
	player.leaderstats.Kills.Value = 0
end)

NOTE: Some parts of the script are not relevant to what is written, included because will add more later on.

I think the problem is when you are checking what team they are in you didnt say BrickColor.new you only said a string value.

When switching a players team, it does not check Player.TeamColor, in other words, BrickColor is the proper value for switching.

To clarify you checked what the team color is with a string value. You should have checked with a BrickColor.new value.

In the image below, red is is the variable previously created, it’s already a string value, so it wouldn’t make a difference due to it being defined in local blue = "Bright blue" local red = "Bright red" local fossil = "Fossil"
image

The problem is that it is a string value. You wrote if lolplayer.TeamColor == blue when you should have wrote if lolplayer.TeamColor == BrickColor.new(blue).

That didn’t work either, unfortunately. Anyway, I’ll be getting to bed, I’ll just let the replies come in.

Did you do BrickColor.new for all of them?