A small question

Ok, so basically I want to make a script where as soon as you join it makes it join a certain team based on your group ROLE not rank. Is it possible to make a user join a team upon joining the game based on their role? NOT RANK!!

So for example if a players joins the game and I want to use GetRoleInGroup() I want to make it so that players spawn in a team based on their role. So if developers+ they join the dev team. If members - vip, they join the players team. I want to make it so that I can script their team change off a group role not a rank. I just want to know if it is possible.

It is possible. And not very hard to make it.

But how? I can’t find out how? Do we have to detect string or something?

You can do it like

player.Team = game.Teams:FindFirstChild(player:GetRoleInGroup(GroupId))

Or like this and then add there when player leaves if in the team is not anyone it deletes etc.

if not game.Teams:FindFirstChild(player:GetRoleInGroup(GroupId)) then
   local team = Instance.new("Team")
   team.Name = player:GetRoleInGroup(GroupId)
  --Setting other props like color, parent etc.
end
player.Team = game.Teams:FindFirstChild(player:GetRoleInGroup(GroupId))
1 Like

If you would need any other help you may mention me.

(Small correction, Instance.new is misspelled in your script.)

Anyways, a quick comment on @bestspyman’s solution:
It’ll make teams and name them integers, not actual words like “Developer.” If someone’s group is 255, their team will be named “255.”

EDIT: Disregard everything I said about integers and stuff, turns out I got the two functions mixed up.

No it won’t name it 255 etc. cause I was using GetRoleInGroup and not GetRankInGroup… So the names will be the words like “Developer” etc.

1 Like

Oh yea, I mixed up the two. My bad. I edited my previous reply.

@bestspyman ok so one more question, how do I put the player in an existing team like “high ranks”. Based off their role in the group? So like lets say a developer joins the game they join the high ranks team.

script checks their role and if it matches a certain role they go to that team.

in other words, I want to make it so that multiple group roles spawn in an existing team

I would do that with the GetRankInGroup() like this:

if player:GetRankInGroup(GroupId) >= MinimalRankNeeded then
      player.Team = Team
end

You also make a directory with a rank number, and then a BrickColor of the respective team. Like this.

local Index = {
[1] = BrickColor.new('Baby blue'),
[2] = BrickColor.new('Black')
}

local groupId = groupid

game.Players.PlayerAdded:Connect(function(player)
local rank = player:GetRankInGroup(groupId)
player.TeamColor = Index[rank]
end)

Yeah but here you must go through all the ranks so if you have many ranks in group and you want to devide them into for example 3 teams then my version is better…

I was giving an instance where he could name the team whatever he wanted, and just index it by brick color. No need to be rude, we’re all here in peace :blush:

I didn’t want to be rude I just wanted him to know when to use mine version and when yours.

I think the use of either script is pretty obvious by a single glance, but sure

Yeah I agree but still I would hate to add 20 ranks to a table when I would have 3 teams… I mean when you have same number of teams and number of ranks then I would probably use yours or if I would have there more groups but I think your version is too complex for this simple thing.