How can I check if someone is on a team?

Hello,

So I am trying to make a script and I require to know if the player is on a team or not. I should know how to do this but my brain has just gone blank. Anyone got any ideas.

1 Like

You can use the following snippet to determine if they’re on any team in the game:

local function isPlayerOnTeam(player)
return player.Team
end

If you want to know if they’re on a specific team, you could also do:

local function isPlayerOnTeam(player, teamName)
return player.Team and player.Team.Name == teamName
end
2 Likes

something like…

if Player.Neutral == true then
	print("No Team")
	elseif Player.Neutral == false then
	print("Team")
end

no, you must use:

if Player.Team == nil then
  print("no team")
end

probably more efficient but I don’t like efficiency

You can also just write it in conditionally one time without functions, don’t know what makes more sense for OP.

if player.Team ~= nil and player.Team.Name:match("TestTeam") then
	print('test')
end