Is there a way to find if a player is in a team?

Hello, I was making a group rank script, but I have divisions for groups, Instead of adding a bunch of group ID’S is there a way to find if a player is in a team?

If you are using Team Service built in to roblox you can

local player = game.Players.builderman
if player.Team then
   print(player.Team)
end
2 Likes

In the case of working with divisions in groups, you will have to manually add in each group ID.

However, if each division is a literal Team object in your game, you can follow @Wizard101fire90 's suggestion.

Is there no way to make it show what team your on?

I’m not sure what you mean. If you have a group for each division, then just check each one by it’s ID. If your players are in teams, do Player.Team to get the team name, and place it in a GUI above their head or however you’re going to show their division.

No no, each division has a team for it, which auto teams them, I just need it so it displays their team. for Example above their head it says “CIVILIAN” or “POLICE” or “ERT” etc.

image Would that work?

That’ll error, change the second thing to player.Team.Name (Player.Team is an Instance)
The old result would be: Attempt to compare string with Instance I believe

Thanks so much I will try it! :smiley:

image Why wouldnt this work?

No clue, can you add print statements to see what gets added and what doesn’t?

I do also see this as well:

local nametag = rep.TeamText
...
local newtext = nametag:Clone()
local teamtext = newtext.TeamText

Did you mean to just put 1 TeamText or 2?

you can use tostring() to convert player.Team into a string

teamtext.Text = tostring(player.Team)

I only meant to do 1, did I do something wrong?

image

Is there a way to find a teams color?

Change local teamtext = newtext.TeamText to local teamtext = newtext.Text, TeamText isn’t a property inside TextLabels I don’t believe

You are missing an end, and a ) to your current end.

        teamtext.Text = player.Team.Name -- or tostring(player.Team)
    end)
end)

I also highly suggest that you use a :WaitForChild() on the humanoid and head , since this fires when the character model is created, so the humanoid and the head might not exist yet.

player.Teams.Team1.TeamColor
1 Like