*Help* Dynamic team selection!

Hi guys I am looking for a bit of help with something which I am a bit stumped on.
I want to make a timer once a player has spawned to have a 1/5 chance of changing team.

So I am guessing this would be scripted in the ini.lua file and would be in function GM:PlayerInitialSpawn( ply )

So this is the pseudo code which I would like a little bit of help with.

timer.Simple( 20, do a calulation for a 1/5 chance for a team change. if successful then clients team from ply:SetTeam( 1 ) to ply:SetTeam( 11 ) else ply:SetTeam( 1 ) end)

I am a little bit stuck so if anyone could help me I would be very appreciative!



[lua]function GM:PlayerSpawn(ply)
timer.Create(“swapteam_”…ply:UniqueID(), 20, 1, function()
if math.random(1, 100) <= 20 then
ply:SetTeam(teamhere); – If you want to change to a random team, then have a table of the teams, and check if the players team is that one.

Thanks, this is an interesting way of doing it! I also found another method which was helpful and works.

But I removed the timer.

if ply:Team() ~= Contenders and math.random(1,5) == 1 then
	ply:SetTeam( 11 )