How do I make a team from a script and assign the player that team upon entering the game?
I'm trying to make a script so when a player enters the game;
1. A team will be created.
2. The team's name will be the player's username.
3. The colour will be random.
4. Assign the player to that team.
And also it should delete the team the player was on when the player leaves.
When I test it, the player joins 'Neutral'.
I have a spawn there so the player spawns where I want it.
When I take off neutral on the spawn, the spawn 'doesn't exist' anymore (the player doesn't spawn there)
This is what I have so far;
1 | game.Players.PlayerAdded:connect( function (player) |
2 | local team = Instance.new( 'Team' ) |
3 | team.Parent = game.Teams |
4 | team.Name = "" ..player.Name.. "" |
5 | team.TeamColor = BrickColor.Random() |
6 | player.TeamColor = BrickColor.new(team.TeamColor) |
I'm sorry for the long question/description.
Answers are greatly appreciated! :)