Need help, I'm a begginer.

Basically I have two teams. Is there a way to make it so when a player joins the server they would get moved to the team with the least players straight away?

Thanks a lot!

[lua]function hi( ply )
if (team.NumPlayers(1) < team.NumPlayers(2)) then
elseif (team.NumPlayers(2) < team.NumPlayers(1)) then

hook.Add( “PlayerInitialSpawn”, “978857645768608678696”, hi )[/lua]

Something along those lines for a noob to understand

You could also use this

that too

Thanks! And that would go into init.lua correct?

yeah, or shared.lua if you are using wakeboarder’s method

Mine can be used on server aswell. The example it gives
function GM:PlayerInitialSpawn( ply )
self.BaseClass:PlayerInitialSpawn( ply )
ply:SetTeam ( team.BestAutoJoinTeam() )

is used in init.lua

don’t call self.BaseClass:PlayerInitialSpawn()

it gives my gamemodes an error that stops the gamemode from loading.

Even if i do it on a gamemode with literally nothing in it