[HELP] Functions Break After A While

[lua]function MayorDemote( victim, weapon, killer )

if victim:Team() == TEAM_MAYOR then
    victim:ChangeTeam(TEAM_CITIZEN, true)
    victim:ChatPrint("You were killed and have lost mayor.")
    for k, v in pairs (player.GetAll()) do     
        if v != victim then    
            v:PrintMessage(HUD_PRINTCENTER, "The Mayor has been shot and killed")                 
            if v:Team() == TEAM_VICE then                        
                v:ChangeTeam( TEAM_MAYOR, true )                        
            end                     
		end
             
    end
         
end


	if victim:Team() == TEAM_MOB then
	if killer:Team() == TEAM_GANG then
		killer:ChangeTeam(TEAM_CITIZEN, true)
		killer:ChatPrint("You killed the mobboss, so you have been demoted.")
	else
		victim:ChangeTeam(TEAM_CITIZEN, true)
		victim:ChatPrint("You have passed away, you are now a citizen.")
	end
end

end
hook.Add( “PlayerDeath”, “mayorDemote”, MayorDemote )

local NoAttackie={TEAM_POLICE,TEAM_CHIEF,TEAM_SWAT,TEAM_swat_leader,TEAM_swat_sniper,TEAM_VICE}
function playershouldtakedamage(victim, attacker)
if victim:Team() == TEAM_MAYOR && table.HasValue(NoAttackie,attacker:Team()) then return false end
end
hook.Add( “PlayerShouldTakeDamage”, “playershouldtakedamage”, playershouldtakedamage)

[/lua]

These are made to demote the mayor when he dies, and made so he can’t take damage from Government officials… the only problem is that the mobboss one, and the damage from government officials stops working after a while…

Why could this be happening?

EDIT: this is for DarkRP… its inside init.lua

[lua]

function MayorDemote( victim, weapon, killer )

if victim:Team() == TEAM_MAYOR then
    victim:ChangeTeam(TEAM_CITIZEN, true)
    victim:ChatPrint("You were killed and have lost mayor.")
    for k, v in pairs (player.GetAll()) do     
        if v != victim then    
            v:PrintMessage(HUD_PRINTCENTER, "The Mayor has been shot and killed")                 
            if v:Team() == TEAM_VICE then                        
                v:ChangeTeam( TEAM_MAYOR, true )                        
            end                     
		end
             
    end
         
end

	if killer:Team() == TEAM_GANG and victim:Team()==TEAM_MOB then
		killer:ChangeTeam(TEAM_CITIZEN, true)
		killer:ChatPrint("You killed the mobboss, so you have been demoted.")
		victim:ChatPrint("You have passed away, so you are now a citizen.")
	end
    //I couldn't figure out what you were doing here..

end
hook.Add( “PlayerDeath”, “mayorDemote”, MayorDemote )
[/lua]

and change the name of the hook and function name for playershouldtake damage, since its on the wiki you might have a mod that is using that.