God mode with certain jobs

Hello so Im trying to make it so when people who are the admin job become that job they have god mode and when they switch back to a different job rather than the job with god mode it will ungod them. i tried to make something but it doesn’t work any help

local function AdminGods(ply)
if ply:Team() == TEAM_ADMIN then
hook.Add(“PlayerSpawn”, “AdminGods”, AdminGods)

Iv tried to add it under my job but it takes out all of the jobs that are custom if this is right and there is nothing wrong with this function an im just putting it in the wrong spot can someone let me know and where i need to put it?

Ofcourse it won’t work, it’s hooked to PlayerSpawn which executes hooked function when (surprise, surprise) player spawns.

Well thats the only way that i can try to get it to work any help

[editline]19th March 2014[/editline]

So if i wanted to do it so when they change teams i would add Hook name OnPlayerChangedTeam( Player ply, number before, number after )
Or just OnPlayerChangedTeam