Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I check if a player is on a particular team?

Asked by 6 years ago

I did do a google search but could find nothing on this topic. Probably me being stupid lol. If someone could direct me to the api or give me the roblox function(if there is one). When a player leaves the game I want to destroy the team but have no way of knowing if they are on a team. I know you can do player.Team but from what I know that could error right(if they don't have a team)? I don't automatically set the player's team at the beginning of the game.

0
Player.Team and use an if to detect if they’re ob a team before you try to use it ThatPreston 354 — 6y

2 answers

Log in to vote
1
Answered by
Troxure 87
6 years ago

You could do this to safely check if the player is on a team.

if(Player.Team) then
print(Player.Team);
end

Hope this helps you!

0
Thanks! Will try this out and accept your answer as soon as I can. User#21908 42 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago
if game.Teams:FindFirstChild(player)  then

-- stuff

end

Hope this helps.. :D

0
That is wrong. Player instances are created under the Players service, not in the Teams. User#19524 175 — 6y

Answer this question