-- assign plr to team
game.Players.PlayerAdded:Connect(function(plr)
--add to default team first
local defaultteam = game.Teams.TeamQueue.Name
if not plr.Team then
plr:GetPropertyChangedSignal(defaultteam):Wait()
end
--
if plr.Team.Name ~= "TeamQueue" then
print(plr.Name.."already in a team")
return
elseif plr.Team.Name == "TeamQueue" then
local teams = game:GetService("Teams"):GetTeams()
for _, team in pairs(teams) do
local players = team:GetPlayers()
if #players <= 0 then
plr.Team = team
print(plr.Name.." assigned to "..team.Name)
break
elseif #players >= 1 then
return
end
end
end
end)
--
when I start a localserver, and then add players to it, the new players did not get assigned a team other than "TeamQueue".
