onplayerchangedteam help

hey so I have been trying but cant figure out how to make an admin job have god mode when they change teams i know that i have to use onplayerchangedteam hook but im not sure how to use it can someone help this is what i got

[lua]
local function AdminGods(ply)
if ply:Team() == TEAM_ADMIN then
ply:GodEnable()
end
end
hook.Add(“OnPlayerChangedTeam”, “AdminGods”, AdminGods
[/lua]

i dont think im doing this right because it wont work.
Can anyone tell me how to do this correct?




hook.Add("OnPlayerChangedTeam", "AdminGods",function( ply, prechange, postchange )
if SERVER then
 if postchange == TEAM_ADMIN then
  ply:GodEnable()
   else
  ply:GodDisable()
 end
end
end)

That should work.

http://forum.facepunch.com/showthread.php?t=1377665

You literally just had a thread, why not use that?

ok so iv put it in garrysmod\lua\autorun and in a folder i made named it godmode.lua and it didnt work am i putting this is the wrong spot

Edited my original post, try that.

is where i put it correct?

[editline]20th March 2014[/editline]

if it is then it doenst work

OnPlayerChangedTeam is definitely a server side hook.

Im a noob with this stuff little help thats why i posted here so where does the side server hook go?

lua/autorun/server/anewfile.lua

Should help you get to know where server/client files go, back a folder into autorun is SHARED between both server/client.