Auto Teaming Players

I was wondering how I would auto team specific players onto a specific team. using a script.

1 Like

Could you please give more information on what you’re trying to achieve?

You can change player’s team with

player.TeamColor = game.Teams.Police.TeamColor

or

player.Team = game.Teams.Police

When an owner joins it auto teams to their assigned role. I would like it it so that is is done via the user id image

Well, it all depends on how you check the role. If it’s a group rank then use player:GetRankInGroup or player:GetRoleInGroup.

Or you could also assign by using Player Names/IDs

1 Like

Its not in the group what i mean is like this:

Local PlayerID = PlayerId

If PlayerID = 12313335,
         player.team = game.Teams.Developer
else:
        player.team = game.Teams.Visitor

I know that is not how you script but that is what I mean.

1 Like

If you’re using GetRankInGroup then do something like this

game.Players.PlayerAdded:Connect(function(plr))
if plr:GetRankInGroup(groupIDhere) == rankHere then
plr.Team = game.Teams.TeamHere
1 Like

I’m not using a group. I’m using player ID’s

ok so you could do something like

local owners = {123456789, 99999999} -- Random User IDs, put UserIds here
game.Players.PlayerAdded:Connect(function(plr))
if table.find(owners, plr.UserId) then
plr.Team = game.Teams.Owners
1 Like

Hold On, I’ll test this in Studio

You forget the ends and its a function statement

local owners = {123456789, 99999999} -- Random User IDs, put UserIds here
game.Players.PlayerAdded:Connect(function(plr)
if table.find(owners, plr.UserId) then
plr.Team = game.Teams.Owners
end
end)

Is there a way of doing this way

[1] = {
			["ID"] = 000000, -- User ID
			["Name"] = "Player Name Here", -- Player name (not required, only for your reference)
			["Team"] =  Owner --Team that you want the person to be ranked to
		},

oh yeah lol sorry i forgot to put ends since it’s not studio

1 Like

Yeah the ends are hard once you have to type them.

It’s simpler to do it the other way but yes I think there is

The reason I want it like this is because it will be a lot easier for the client to change.

Do you know how to do it in that format?

No sorry, I usually use tables instead of dictionaries.
But I’ll recommend this article to you: https://education.roblox.com/en-us/resources/intro-to-dictionaries---series

1 Like