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 5 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 — 5y

2 answers

Log in to vote
1
Answered by
Troxure 87
5 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 — 5y
Ad
Log in to vote
-1
Answered by 5 years ago
Edited 5 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 — 5y

Answer this question