Having Issue With Roblox's Team System

I’m trying to create an FPS game. One of the maps I’m working on is going to be a “Squads” (5v5v5v5) map. When the teams are created the game doesn’t evenly put all the players onto a team instead it adds a neutral team and forces every player to be on the neutral team.

Heres what happens:
Intermission > The Map Loads > The Map Creates 4 Teams > All 4 Teams Are Created & A Neutral Team Is Created > All Players Are Put Onto The Neutral Team

I didn’t have this issue when I added all 4 teams into Roblox Studio myself but when I try to make the server add the teams it doesn’t work correctly.
I’ve never worked with teams before as I’m a fairly new developer on Roblox. Any advice would help me out a ton!

1 Like

You need to attach the code you are using to achieve this, otherwise we are not able to help you. My suspicion is that you are teaming players incorrectly to a team that doesn’t exist, causing them to be teamed to Neutral.

4 Likes

There isn’t any code that adds the players to the team. I thought if I inserted the teams via a script then the players would automatically be added to the teams like how they are if you add the teams while In Roblox studio. Maybe this is where my confusion is coming from. I didn’t realize that I’d have to team them myself.

1 Like

Yes, if you enable AutoAssignable in the team properties then this is the case, however, it is still relevant to attach the code you use to create those teams…

Inside the map I loaded there’s a SpawnLocation. Inside the SpawnLocation, I inserted a “Team”. Inside the “Team” I placed this script: script.Parent.Parent = game.Teams so that the team is place into game.Teams and the team is created.
image

Try script.Parent.Parent = game:GetService("Teams")

Alternatively, use the button that inserts services (somewhere in the topbar, right side) and drop the teams under the service created in the explorer.

I just made a post about players getting asigned to a team, and got solution:

This is generally bad practice. By doing this you are creating a new Script inside a Team, which is inside a Spawn, for every time you want to make a Team.

The ideal way to do this is to use a singular script to create a team with the appropriate properties, and to parent it to Teams.

Insert a Script in ServerScriptService with this code:

local Teams = game:GetService("Teams")

local BlueTeam = Instance.new("Team")
BlueTeam.Name = "Blue"
BlueTeam.TeamColor = BrickColor.new("Bright blue")
BlueTeam.AutoAssignable = true -- Players are auto-assigned
BlueTeam.Parent = Teams -- Put the team inside "Teams"

local RedTeam = Instance.new("Team")
RedTeam.Name = "Red"
RedTeam.TeamColor = BrickColor.new("Bright red")
RedTeam.AutoAssignable = true
RedTeam.Parent = Teams
This was typed on mobile so there may be unintended errors.

This will create a Red and Blue team, with the given properties and parent them to Teams at runtime.

Scripts will not run in the Team object (or at least I think they don’t). You need to (or should) create the teams from a completely separate script and parent them to the Teams service. There are some things you need to make sure of from your end as well: such advisories are on the Team object documentation page.

In terms of assigning players to teams, you need to code this behaviour yourself. AutoAssignable will only take effect for newly joining players, so any players currently in the game will retain team neutrality and will not be reassigned to a team.

For creating teams, see the above code for an example. It just has one mistake (cc @H_mzah): the Team has TeamColor. So instead of Team.BrickColor = BrickColor, Team.TeamColor = BrickColor.

In terms of readying players to get on teams, you’ll have to come up with a way to sort all players in a given server amongst your teams. You will also need to iterate through all players in the game and set their Neutral property to false before assigning them a team.

-- Example
Player.Neutral = false
Player.TeamColor = BrickColor.new("Bright red")
3 Likes

So, I know how to set their Neutral to false

for i,v in pairs (players:GetPlayers()) do
            	v:Neutral = false end

but I don’t know how to evenly disperse the players among the four teams

1 Like