"attempt to index local 'pl' (a nil value)" help...

The error:


[ERROR] lua/autorun/client/phtm_client.lua:32: attempt to index local 'pl' (a nil value)
  1. v - lua/autorun/client/phtm_client.lua:32
   2. Call - lua/includes/modules/hook.lua:84
    3. _func - lua/autorun/client/phtm_client.lua:21
     4. v - lua/autorun/client/phtm_client.lua:877
      5. unknown - lua/includes/modules/hook.lua:84


Line 21 code:


	function IsAlive(pl)
		if ( pl:Alive() && pl.MenuOpen != 1 ) then //Line 21
			hook.Call("TeamCheck")
		else
			if ( pl.MenuOpen != 0 ) then 
				chat.AddText(Color(214,0,0),"[Taunt Menu]", Color(0,225,126)," Menu is already open.")//Chat message for player.
			else
				chat.AddText(Color(214,0,0),"[Taunt Menu]", Color(0,225,126)," You are dead, you need to be alive to use this.")//Chat message for player.
			end
		end	
	end

Line 32 code:


	function TeamCheck(pl)//Line 32
		if pl:Team() == 1 then
			hook.Call("phm_p1")
		else
			if pl:Team() == 2 then
				chat.AddText("You are on props")
				hook.Call("phm_p1")
			else
				chat.AddText("You do not have a team assigned")
			end
		end
	end

Line 877 code:


	local FKeyMenus = {
		KEY_F4 = IsAlive;
		KEY_C = IsAlive;
	};
	hook.Add( "PlayerBindPress", "PlayerBindPressFKeyMenus", function( _p, _bind, pressed )
		local _key = "KEY_" .. string.upper( input.LookupBinding( _bind ) );
		local _func = FKeyMenus[ _key ];
		if ( _func ) then  //Line 877
			_func( LocalPlayer() );
		end 
	end);

I can’t figure out as to why I keep getting this annoying error.

Please help.

Don’t just call
[lua]hook.Call(“TeamCheck”)[/lua]
You have to give it arguments, use hook.Run instead, it does the same but it’s simpler
[lua]hook.Run( “TeamCheck”, pl )[/lua]
Replace your hook.Call with that.