Round code keeps looping over and over again...


function GM:SetSpy( ply )

	GAMEMODE.Spy = ply
	ply:SetModel( GAMEMODE.Models["spymodel"] )
	ply:SetupHands()

end

function GM:SetSoldier( ply )

	table.insert( GAMEMODE.Soldiers, v )
	ply:SetModel( GAMEMODE.Models["soldiermodel"] )
	ply:SetupHands()

end

function GM:HandleIt()

	local rand = table.Random(player.GetAll())

	for k, v in pairs(player.GetAll()) do
	
		if v != rand then
		
			GAMEMODE:SetSoldier( v )
			
		else
		
			GAMEMODE:SetSpy( v )
		
		end
	
	end

	SetGlobalBool( "InRound", true )

end

function GM:Think() -- yes, not in sv_gmfuncs

	if !GetGlobalBool( "InRound" ) and #player.GetAll() > 1 then
	
		GAMEMODE:HandleIt()
		print("handled!")
	
	end
	
	if GetGlobalBool( "InRound" ) and #GAMEMODE.Soldiers == 0 or GetGlobalBool( "InRound" ) and GAMEMODE.Spy == nil then

        -- we don't do any "alive" checks because gamemode.soldiers loses values when a player in it dies and gamemode.spy is set to nil when the spy dies
	
		print("should end")
		SetGlobalBool( "InRound", false )
	
	end
	
end

The result is as follows in the console:


handled!
should end
handled!
should end
handled!
should end
handled!
should end
handled!
should end
...

So, my round code keeps on looping and looping for no reason.

Well, its kinda called all the time? What do you need? Call it just 1 time?

Oh shit shit shit, I think I just realized my error :v: