Function that runs when a player changes team

Alright, I need a function that runs when a player’s team is changed.

If I where to go [lua]ply:SetTeam(2)[/lua] It would have to run.

I have tried various functions like [lua]function GM:OnPlayerChangedTeam( ply, oldteam, newteam )[/lua][lua]function GM:PlayerJoinTeam( ply, teamid )[/lua]I also tried this one, which probably wouldn’t work seeing as it only runs when the player uses the changeteam command. Still gave it a shot though.
[lua]function GM:PlayerRequestTeam( ply, teamid )[/lua]

For some reason none of these run when I do that, although a couple run when I use the changeteam command. So do I need to change the player’s team in a different way? Why do you think this doesn’t work?

Well what exactly are you trying to do?

I already found a work around for my issue, but I still would like to figure this out. What’s happening in the function doesn’t matter, I put a print statement inside of them to see if they ran, and they didn’t.

Try calling it as a hook.

You know, that seems like a good idea. XD