Client side script, checking which team the player is on..?

Well I created a Derma Menu, I want to make that the client side checks whether the player is Team A or Team B and open the proper menu of that team.

Any ideas how can I call a check on that from the gamemode?

Appreciate the help!
//Vash Baldeus

if ply:Team() == 1 then
//Stuff
elseif ply:Team() == 2 then
//Stuff2
else
//otherwise
end

This will get players team state and do something accordignly?

Thanks!

Yup.
If you do not know the ids of the teams run this:



for k,team in pairs(team.GetAllTeams()) do
      print("Name: "..team:GetName(team).." | ID: "..team)
end


for clients, it’s LocalPlayer():Team()

I get this error when trying to get the team id:


[ERROR] lua/autorun/client/phtm_client.lua:648: attempt to call method 'GetName' (a nil value)
  1. _func - lua/autorun/client/phtm_client.lua:648
   2. v - lua/autorun/client/phtm_client.lua:671
    3. unknown - lua/includes/modules/hook.lua:84



The code:


	function GetTeam()
		print("GetTeam() was Called")
		for k,team in pairs(team.GetAllTeams()) do
			  print("Name: "..team:GetName(team).." | ID: "..team)
		end
	end

It’s team**.**GetName

Yeah, sorry use . instead of :

Same error…


[ERROR] lua/autorun/client/phtm_client.lua:649: attempt to call field 'GetName' (a nil value)
  1. _func - lua/autorun/client/phtm_client.lua:649
   2. v - lua/autorun/client/phtm_client.lua:674
    3. unknown - lua/includes/modules/hook.lua:84


the code as it looks now after fixing the typeout:


		print("GetTeam() was Called")
		for k,team in pairs(team.GetAllTeams()) do
			  print("Name: "..team.GetName(team).." | ID: "..team)
		end

Oh i am sorry, i defined team as a key and its probably more intelligent to use the key instead of the vlaue. Dumb me
Try this



print("GetTeam() was Called")
		for k,v in pairs(team.GetAllTeams()) do
			  print("Name: "..team.GetName(k).." | ID: "..k)
		end


Thanks allot for the help, works!