Heyo, late response but if you have not figured it out yet here you go.
The reason your code does not work is because you need to use the :GetPlayers method to get the amount of players in a certain team. Right now you’re just putting a # next to your Team variable. # gets the length of a table, while :GetPlayers returns a table of all the present players. That is why if you were to do #Team1:GetPlayers() you would get the amount of players on Team1. This code should work in theory, but no guarantees
:
game.Players.PlayerAdded:Connect(function(plr)
local Team1 = game.Teams.Plr1
local Team2 = game.Teams.Plr2
local Team3 = game.Teams.Plr3
local Team4 = game.Teams.Plr4
local Team1Players = #Team1:GetPlayers()
local Team2Players = #Team2:GetPlayers()
local Team3Players = #Team3:GetPlayers()
local Team4Players = #Team4:GetPlayers()
if Team1Players == 0 then
plr.Team = Team1
print("placed on team1")
elseif Team2Players == 0 then
plr.Team = Team2
print("placed on team2")
elseif Team3Players == 0 then
plr.Team = Team3
print("placed on team3")
elseif Team4Players == 0 then
plr.Team = Team4
print("placed on team4")
elseif Team4Players > 0 then
print("no space")
end
end)
Also you don’t need to do teams.Plr1 as you already set variable Team1 to teams.Plr1 so you could just use the name of the variable to change the player’s team.
Good luck!