Max Team Script not working?

So im making a game and i want each of the 2 teams to have a max limit
i tried doing < 5 so only 5 players can join the team but it doesnt seem to be working?
can you help me out?

game.Players.PlayerAdded:Connect(function(plr)
	local Max_Hiders = Teams.Hider:GetPlayers()
	local Max_Seekers = Teams.Seeker:GetPlayers()
		if #Max_Hiders < 4 then
			plr.Team = Teams.Hider
		else
		if #Max_Seekers < 1 then
			plr.Team = Teams.Seeker
		end
	end
end)

What have you tried doing to fix the issue?

game.Players.PlayerAdded:Connect(function(plr)
	local Teams = game:GetService("Teams")
	
	local Max_Hiders = Teams.Hider:GetPlayers()
	local Max_Seekers = Teams.Seeker:GetPlayers()
	if #Max_Hiders < 4 then
		plr.Team = Teams.Hider
	elseif #Max_Seekers < 1 then
		plr.Team = Teams.Seeker
	end
end)

You need to define Teams, try

1 Like

Thank you for helping me out much appreciate :+1: