Spawnpoint need help

Heu guys im now creating a gamemode and my spawnpoint is not working hope someone can help me here this is the code is use

local teams = {}

teams[0].spawnpoint[1] = Vector(1635.777710,-1943.107056,-79.968750)
teams[0].spawnpoint[2] = Vector(1616.266235,-1173.823853,-79.968750)
teams[0].spawnpoint[3] = Vector(1245.563721,-1110.635254,-79.968750)

teams[1].spawnpoint[1] = Vector(-4528.927734,4827.819336,-31.968750)
teams[1].spawnpoint[2] = Vector(-4911.646484,5239.514648,-31.968750)
teams[1].spawnpoint[3] = Vector(-4597.583496,5890.459473,-31.968750)

ply:SetPos(table.Random(teams[0]))

ply:SetPos(table.Random(teams[1]))

You aren’t initializing the spawnpoint table member.

[lua]
local teams = {}

teams[0].spawnpoint = {}
teams[0].spawnpoint[1] = Vector(1635.777710,-1943.107056,-79.968750)
teams[0].spawnpoint[2] = Vector(1616.266235,-1173.823853,-79.968750)
teams[0].spawnpoint[3] = Vector(1245.563721,-1110.635254,-79.968750)

teams[1].spawnpoint = {}
teams[1].spawnpoint[1] = Vector(-4528.927734,4827.819336,-31.968750)
teams[1].spawnpoint[2] = Vector(-4911.646484,5239.514648,-31.968750)
teams[1].spawnpoint[3] = Vector(-4597.583496,5890.459473,-31.968750)

ply:SetPos(table.Random(teams[0]))

ply:SetPos(table.Random(teams[1]))

– Or create a helper function, makes code a lot prettier:

local function AddTeamSpawnpoint( iTeam, vPosition )
if not teams[iTeam] then teams[iTeam] = {}; end
table.insert( teams[iTeam], vPosition );
end

AddTteamSpawnpoint( 0,Vector(1635.777710,-1943.107056,-79.968750) );
AddTteamSpawnpoint( 0,Vector(1616.266235,-1173.823853,-79.968750) );
AddTteamSpawnpoint( 0,Vector(1245.563721,-1110.635254,-79.968750) );

AddTteamSpawnpoint( 1,Vector(-4528.927734,4827.819336,-31.968750) );
AddTteamSpawnpoint( 1,Vector(-4911.646484,5239.514648,-31.968750) );
AddTteamSpawnpoint( 1,Vector(-4597.583496,5890.459473,-31.968750) );

local function SelectSpawnPoint( ePlayer )
if ( teams[ ePlayer:Team() ] ) then return table.Random( teams[ ePlayer:Team() ] ); end
return false; – Do an if statement
end

local function SpawnPlayer( ePlayer )
local vSpawnPoint = SelectSpawnPoint( ePlayer );
if ( vSpawnPoint ) then
ePlayer:SetPos( vSpawnPoint );
end
end
[/lua]

Thanks you for you help its now working