Team Changer FE is not working?

Ok so I made a team change gui today and I want to know how to fix this because I am trying to make the team change gui fe but when I play the game and pick my team it doesn’t work.

LocalScript: (This isn’t the full script but it is where the problem is)

  for i = 1, #selectableTeams do
    local column = math.floor(i / buttonsPerColumn)
    do
      local button = Instance.new("TextButton", selectionFrame)
      button.Visible = true
      button.Position = teamButtonOffset + UDim2.new(0, column * teamButtonXIncrement, 0, (i - column * buttonsPerColumn) * teamButtonYIncrement)
      if column == 0 then
        button.Position = button.Position - UDim2.new(0, 0, 0, teamButtonYIncrement)
      end
      button.Size = UDim2.new(0, teamButtonSize.X, 0, teamButtonSize.Y)
      button.BackgroundTransparency = 1
      button.Text = selectableTeams[i]
      button.FontSize = Enum.FontSize.Size14
      button.TextXAlignment = "Left"
      button.TextColor3 = Color3.new(1, 1, 1)
      local label = Instance.new("TextLabel", button)
      label.Size = UDim2.new(0, 4, 1, 0)
      label.Position = UDim2.new(0, -8, 0, 0)
      label.Text = ""
      label.BackgroundColor3 = Color3.new(1, 1, 1)
      label.BorderSizePixel = 0
      if Game:findFirstChild("Teams") then
        local team = Game.Teams:findFirstChild(selectableTeams[i])
        do
          if team then
            do
              label.BackgroundColor3 = Game.Teams:findFirstChild(selectableTeams[i]).TeamColor.Color
              button.MouseButton1Click:connect(function()
	if not confirmed then				
	  workspace.TeamEvents.TeamEvent:FireServer(player,team) -- The problem is here!!!			
	 --  player.TeamColor = team.TeamColor -- If I uncomment this then it will work but its not fe
      confirmed = true
      selectionFrame:ClearAllChildren()

Server Script that makes it FE:

script.Parent.OnServerEvent:Connect(function(player,team)
        player.TeamColor = team.TeamColor
end)

I don’t get why this isn’t working. I looked everywhere and I still cannot find the problem thats cuasing it.

Hello Sp00ked1,

Can you give me the error message?

There is no error message when I click the team it kills me (ingame) but it doesn’t change my team.

Try to replicate the team color and not the team.

FireServer(plr, TeamColor)
OnServerEvent:Connect(fnc(plr, color)
plr.TeamColor = BrickColor.new(color)

Nope not working doesn’t give an error and nothing happens.

It’s okay now because I fixed it.

This is what I did:

Local:

game.ReplicatedStorage.ChangeTeam:FireServer(team)

Its because I put player at the start and then it seemed to work.