Team Change Help

I’ve been watching some event tutorials and decided to take a shot at team changing, it doesn’t work great and I need some help with it.

One issue, I have a small dark room at the bottom of my map with neutral spawns, where the Selecting team spawns. Sometimes when I try switching my team, it still spawns me at the neutral spawns.

My team change script in my gui:

local RemoteEvent = game.ReplicatedStorage.Events2.TeamChange

local frame = script.Parent

local GuardColor = "Lapis"

local InmateColor = "Maroon"

frame.Terrorists.MouseButton1Click:Connect(function()
RemoteEvent:FireServer(BrickColor.new(InmateColor))
end)

frame.Police.MouseButton1Click:Connect(function()
RemoteEvent:FireServer(BrickColor.new(GuardColor))
end)

My serverscript:

game.ReplicatedStorage.Events2.TeamChange.OnServerEvent:Connect(function(player,teamColor)
player.TeamColor = teamColor
player:LoadCharacter()	
end)

Another issue I have is when I go back to the team selection screen, and try to go back to the same team, I stay on the team selection team. When I go back to the menu it puts me on the selecting team, the selecting team has neutral spawns, it’s autoassignable and I don’t know what I’m doing wrong.

You could:
Guard = game.Teams.Guards

ServerScript:
Player.Team = Guard or game.Teams.Guards

Hope it made sense.

If I’m understanding what you’re saying, set the TeamColor of the SpawnLocation to the
“Selecting team” (not sure what you really mean by that.) And make it not neutral.