How to add certain players to a team

Hi,
In this tutorial i will be guiding you through, how to how to add a certain player to a team.

The first thing you need to do is make sure you have a team ready and that AutoAssignable is set to false.

Now that you have the team and have AutoAssignable set to false we can now start scripting.

First off we should start by creating a variable.

local customRole = game.Teams.CustomRole

Change CustomRole to the name of your team that you are assigning to a certain player.

Now that we have created a variable we can now define the player.

game.Players.PlayerAdded:Connect(function(player)

if player.Name == "" then

Be sure to add the players name that you are assigning this team to, inside the speech marks.

Now that we have defined the player we can now assign them to the team.

player.Team = customTeam

Once you’ve finished your script should look like this
Screen Shot 2021-01-09 at 10.01.18 am

Thank you for reading my post, I hope it helped and have a great day!

26 Likes

Always use :GetService() over game.DataModel.
Why?
:GetService() will create a new instance of said Service if it doesn’t exist yet, and if it does exist will ignore the Service DataModel name if it was changed.

Thanks for your contribution though!

3 Likes

Very helpful, I’ll be using this in my game!