Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

0

Player.Team and use an if to detect if they’re ob a team before you try to use it

2 answers

✓ Accepted answer

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!

1 comment

0

Thanks! Will try this out and accept your answer as soon as I can.

if game.Teams:FindFirstChild(player)  then

-- stuff

end

Hope this helps.. :D

1 comment

0

That is wrong. Player instances are created under the Players service, not in the Teams.

This discussion is preserved as it was. New answers, comments, and votes are closed.