Change of command

How can I make a change teams?
I tried this:

[lua]function ChangeMyTeam( ply, cmd, args )
local oldTeam = ply:Team()
ply:SetTeam(“Spy”)
GAMEMODE:PlayerOnChangeTeam(ply, “Spy”, oldTeam)

end
concommand.Add( “set_team”, ChangeMyTeam )[/lua]

Console:
[lua]
] set_team

[ERROR] lua/autorun/client/team.lua:3: attempt to call method ‘SetTeam’ (a nil value)

  1. unknown - lua/autorun/client/team.lua:3
  2. unknown - lua/includes/modules/concommand.lua:54

[/lua]

teams are serverside not clientside.

if serverside then

Unknown command: set_team

Where are you putting the code?

also, Player:SetTeam() takes a number as the first argument, not a string.

What?
Place this function in init.lua or any serverside file. In lua/autorun/server

[editline]23rd April 2015[/editline]

Yes, like James said use the Team Number ( First argument in team.SetUp() )