Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

team assigning script fails to run either from an "if" statement or when more than one player joins?

-- 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".

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.