Team spawn points


Me and a friend of mine (CalzEdz) is making a gamemode. Now, I’m normally the guy who is making the maps, but I can aslo do some code. Now we have a problem with the team spawns (Yes, it’s a team based gamemode). we can’t get the teams to spawn at any spawnpoint at all on the map that I have created. So, basicly how do we create team spawnpoints on a map and how de we do so a teammember spawn there?
This is the error I get:

ERROR: GAMEMODE:'PlayerSelectSpawn' Failed: CTC/gamemode/init.lua:24: attempt to get length of local 'spawns' (a nil value)

Btw, here is the PlayerSelectSpawn code that I have made: (One of MANY that have failed)

function GM:PlayerSelectSpawn(ply)
	if ply:Team() == 1 then
		local spawns = team.GetSpawnPoint( 3 )
		local randomspawn = math.random(#spawns)
		return spawns[randomspawn]
	elseif ply:Team() == 0 then
		local spawns = team.GetSpawnPoint( 2 )
		local randomspawn = math.random(#spawns)
		return spawns[randomspawn]

On my map I have 2 teamspawns. One is set to be the Red team and the another one is set to be the Blue team. (2 and 3).

Thanks in advance, TheRaz.

You don’t have to pick a random spawnpoint, as far as I know the game does that for you.

Well, does it pick a team spawn point?

You could use:
[lua]team.SetSpawnPoint( Team, “spawnpoint” )[/lua]

Use the wiki next time:

It didn’t work before. Byt I solved it by myself now, thanks anyway