My new gamemode that is nearly finished, but not quiet!

Hello,

So i’m making a gamemode for the Garry’s Mod Workshop, and i need a little bit of help, not much at all its just a little bit, iv’e got to say i’m not an expert at lua, but anyways, let me tell you what my problem is :stuck_out_tongue:

I need a spectator team with rounds, and i do not know how to make teams even (so like 5 players on 1 team and 5 players on the other).

That is all i need, but how do i do it? here are my lua files:

shared.lua


GM.Name = "Smash"
GM.Author = "Tubby Shit"
GM.Email = "iitubbytoaster@gmail.com"
GM.Website = ""

team.SetUp(0, "Blue", Color(0, 0, 225) )
team.SetSpawnPoint( 0, {"info_player_counterterrorist","info_player_rebel","info_player_start"} )

team.SetUp(1, "Red", Color(255, 0, 0) )
team.SetSpawnPoint( 1, {"info_player_terrorist","info_player_rebel","info_player_start"} )

function GM:Initalize()
	self.BaseClass.Initalize( self )
end

init.lua


AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")
include("player.lua")

function GM:PlayerConnect( name, ip )
	print("The player ".. name .." has joined this Smash server!")
end

function GM:PlayerInitialSpawn( ply )
	print("The player ".. ply:Nick() .." has joined this Smash Server!")
	ply:SetGamemodeTeam( math.random(1,2) )
end

function GM:PlayerAuthed( ply, steamID, uniqueID )
	print("The player ".. ply:Nick() .." has gotten authed")
end

function GM:PlayerSpawn( ply )

    self.BaseClass:PlayerSpawn( ply )   
 
    ply:SetMaxHealth( 100, true )  
 
    ply:SetWalkSpeed( 230 )  
    ply:SetRunSpeed ( 230 )
	
	ply:SetCollisionGroup( COLLISION_GROUP_DEBRIS_TRIGGER )
	ply:SetModel("models/player/group01/male_0" .. math.random(1,9) .. ".mdl")
	ply:EmitSound( "buttons/combine_button2.wav" )

end

cl_init.lua


include("shared.lua")

player.lua


local ply = FindMetaTable("Player")

local teams = {}

teams[0] = {name = "Blue", color = Vector( .2, .2, 1.0 ) }
teams[1] = {name = "Red", color = Vector( 1.0, .2, .2 ) }

function ply:SetGamemodeTeam( n )
	if not teams[n] then return end
	
	self:SetTeam( n )
	
	self:SetPlayerColor( teams[n].color )
	
	return true
end

*quite

lol thanks xD

Instead of making it math.random, do http://wiki.garrysmod.com/page/team/BestAutoJoinTeam

Thank you!