I have a problem with this code

function Remove ( ply, oldteam, newteam )
if oldteam == TEAM_CITYZEN then
hook.Remove("OnPlayerChangedTeam", "off", SetMaterial)

but can change team material is not removed and bug all jobs F4 menu

Thx for help!

Are you sure it’s TEAM_CITYZEN

yes i have

Try :

hook.Remove("OnPlayerChangedTeam", "off", Remove)

thx for reply

I tested

hook.Remove(“OnPlayerChangedTeam”, “off”, Remove)
hook.Remove(“OnPlayerChangedTeam”, “on”, Remove)

but all jobs f4 menu bug and I no see my setmaterial

hook.Add('OnPlayerChangedTeam', 'Whatever', function(ply, prev, next)
	if prev == TEAM_CITYZEN then

Don’t make a global function for only 1 hook. Also, you were trying to remove hook instead of creating.

thx for reply all jobs f4 menu work now but can I change jobs the
ply:SetMaterial(‘models/shadertest/shader5’) is no remeved

this code give setmaterial but can change for another jobs this is not remove
help me pls

i can use this or something like that

I don’t think this hook/function works with DarkRP as I tried it myself before with some print() statements and nothing ever showed up

One solution is assigning a variable to a player when they first spawn, which holds their team and then use a timer to check if their current team matches that variable

thx for reply

you have exemple code pls ?