Teams - Roblox Advanced Scripting #27 — Transcript
Full transcript
- 0:00Oh, I'm about to make my shot. I'm wide
- 0:02open right now. All right, let's go. No,
- 0:05it's gonna hit the guy. No, I don't want
- 0:07it to hit the guy. Go in the goal. Go in
- 0:09the goal. In the goal. Oh my good. All
- 0:12right, go in. Go in. There we go. That
- 0:16is how you do a score. I am so good at
- 0:18this game. This video is going to be
- 0:21about teams, which is a feature that
- 0:22Roblox has provided to us that we are
- 0:25going to be using inside of this video.
- 0:27And I think it's important to understand
- 0:29why teams are useful to add inside of
- 0:32your Roblox game. But before we start
- 0:34implementing, let me show you um what
- 0:37teams are and how we can use them inside
- 0:39of our Roblox game. All right, let's
- 0:41think about this for a minute. Before we
- 0:43start adding teams inside of Roblox
- 0:45Studio, I I first want to briefly
- 0:47explain what teams actually are and how
- 0:49they serve a purpose for uh Roblox. So I
- 0:53hope you understand the basic idea of
- 0:55what a team is. A team is basically when
- 0:58you group a bunch of people together to
- 1:01achieve the same goal or a similar goal
- 1:04or you can also think of it as a faction
- 1:06as well among specific groups of people.
- 1:09So in this case with this soccer field
- 1:12here we have three players on this side
- 1:14and we have three players on this side.
- 1:16The goal for these three players that
- 1:18are grouped together is to move this
- 1:21ball towards this goal over here. And
- 1:23the goal for these players is to move
- 1:26this ball over to this goal. So each
- 1:28group of players or people have the same
- 1:32goal that they're trying to accomplish.
- 1:34And this can basically be said about any
- 1:37team or group of people trying to
- 1:39achieve the same goal um as a whole. So
- 1:42with that basic understanding of teams,
- 1:44Roblox has provided us a feature to
- 1:46allow us to add these teams inside of
- 1:49our games. So if we have teams, then we
- 1:51can differentiate these players from one
- 1:53another. So this ties back into Roblox
- 1:55because they actually have a built-in
- 1:57feature that allows us to add teams
- 2:00inside of our own game. And that's what
- 2:01I'm going to be showing you how to do
- 2:02inside of this video. So with that being
- 2:04said, let's now go ahead and go straight
- 2:06into implementing. Now that we
- 2:08understand it, let's implement teams
- 2:10inside of Roblox Studio. So, there's
- 2:12going to be a new service that I'm going
- 2:14to introduce to you inside of this video
- 2:16and it's also going to be live in the
- 2:19explorer and that ex and that is called
- 2:22teams. That's going to be down here. So,
- 2:24this is the service we're going to use
- 2:26to add teams to our own game. And the
- 2:28way we're going to do that is by going
- 2:29to the right side, hitting the plus
- 2:31sign, and we're going to insert a team
- 2:33like this. So now we have our first team
- 2:36inside of the team's uh folder inside of
- 2:39the explorer. So if we click on it, then
- 2:41there's a few properties here that we
- 2:42can work with that are unique to a team.
- 2:45So the first property is called auto
- 2:47assignable, which is basically a
- 2:49property that that tells Roblox if we
- 2:51want the player to automatically be
- 2:53assigned to this team if we join into
- 2:56the game. So I'm going to show you what
- 2:57that looks like right now. If we go to
- 2:59test and we go to play, then what we
- 3:01should see is Roblox is going to add us
- 3:03to the team. And the way we can see that
- 3:05is by going on the top right on our
- 3:08leaderboard. We can see that our
- 3:10username is placed right underneath the
- 3:13team that we just created. And so by
- 3:15default, it's this whiteish team with
- 3:18the name simply team. So we can
- 3:20customize this further uh if we go back
- 3:22into Roblox Studio. So let's hit stop.
- 3:24And what we can do is rename this team
- 3:27to something different. We can call this
- 3:30uh let's say green team like this. And
- 3:34the reason I'm going to say green team
- 3:35is because this is what's going to show
- 3:37the next property which is team color.
- 3:39And if we were to click on this team
- 3:40color, then we can pick any one of these
- 3:43colors to be the color of our team. So
- 3:46I'm just going to pick lime green for
- 3:47this example. So now what's going to
- 3:49happen is if we go into the game then we
- 3:51can see again on the top right of the
- 3:53screen that um our color of the color of
- 3:56the team changed and also the name of
- 3:59the team changed to green team. So that
- 4:01is basically what we wanted to see from
- 4:03here. Now another thing is if we add
- 4:06more teams. So if we let's say duplicate
- 4:08this. So, we're going to right click and
- 4:10duplicate it. And we call this one the
- 4:12blue team. And we change the team color
- 4:16to let's say um this color, cyan. If we
- 4:20go into the game again, hit play, then
- 4:22what's going to happen is Roblox is
- 4:24going to randomly put us either in the
- 4:26green team or the blue team. And now
- 4:28there's also two different teams inside
- 4:30of the the leaderboard because we've
- 4:32added multiple teams. And you can
- 4:33basically do this for as many teams as
- 4:35you want. I don't know if there's a
- 4:37limit to how many teams you can have
- 4:38inside of a Roblox game, but you can
- 4:40definitely have a lot of teams, that's
- 4:42for sure. Now, how does Roblox determine
- 4:44which team to put you in if we have
- 4:46multiple auto assignable properties
- 4:48checked since now we have green team and
- 4:50blue team checked? Well, basically what
- 4:52Roblox does is when we join into the
- 4:54game, Roblox is going to put us in the
- 4:57most convenient team first before
- 4:59putting us in the other team to make it
- 5:01balanced. So, what I'm talking about is
- 5:03if we join into the game, Roblox is most
- 5:06likely going to put us inside of the
- 5:07green team first if there's no players
- 5:09in there. But if there's one player
- 5:12inside of the green team and no players
- 5:14inside of the blue team, then Roblox is
- 5:16going to put me inside of the blue team
- 5:18as soon as I join into the game just to
- 5:20keep the teams balanced, if that makes
- 5:22sense. So, if I go into the game and I
- 5:24keep uh trying to refresh my character,
- 5:27then it's always going to put me inside
- 5:28of the green team. But if another player
- 5:30joined into the game, then they would
- 5:31probably be placed inside of the blue
- 5:33team instead just to keep the game
- 5:35balanced that way. Now, if you were to
- 5:37uncheck auto assignable for one of these
- 5:39teams, then Roblox will not put you
- 5:41inside of this team automatically if you
- 5:43join into the game. And it's going to be
- 5:45up to you as the developer to manually
- 5:48put these players inside of the blue
- 5:50team through scripting, which I'm going
- 5:52to show you how to do in just a little
- 5:53bit. But that's how you essentially add
- 5:56teams inside of Roblox Studio. Okay.
- 5:58Now, there's an interesting concept I
- 6:00want you to understand, and that is the
- 6:02use of spawn locations with teams. Now,
- 6:06I want you to understand this. Before I
- 6:08introduce teams to you, basically all
- 6:11players were inside of a neutral team or
- 6:13basically just no team at all. So, if we
- 6:16were to play the game, then all players
- 6:18were basically considered to be neutral
- 6:20because they were not tied to any
- 6:22specific team inside of the game. And
- 6:24because of this, we have what's called a
- 6:27spawn location here, which is
- 6:29essentially a part that allows players
- 6:31to spawn on top of when they join into
- 6:33the game or if they reset their
- 6:34character. So, this spawn location acts
- 6:37as a neutral spawn location where
- 6:39there's no team tied to it specifically.
- 6:42So, if we were to join into the game,
- 6:43we're always going to be spawning on
- 6:45this spawn location no matter what. But
- 6:47what's interesting is now that we have
- 6:48teams, we can have multiple different
- 6:51spawn locations that are specific to uh
- 6:55the teams that we've just created. So if
- 6:57a player was inside of the blue team and
- 7:01this was, let's say, the blue team's um
- 7:03spawn location, then all players that
- 7:05are in the blue team will respawn on
- 7:08this spawn location right here rather
- 7:10than this one or this one. And so right
- 7:13now I'm going to be showing you how to
- 7:14create different spawn locations for
- 7:17different teams. So what I'm going to do
- 7:19is take the spawn location and I'm going
- 7:21to hit Ctrl D to duplicate it and then
- 7:24I'm going to move it alongside this way.
- 7:26Now with this spawn location, what we
- 7:28can do is set a team for this specific
- 7:32spawn location. In this case, we can do
- 7:34the green team. So what I'm going to do
- 7:36is change the brick color to lime green.
- 7:38And I'm also going to scroll all the way
- 7:40down to this property called team color.
- 7:43And I'm going to change this to lime
- 7:45green. Now, it's very important to
- 7:46understand the difference between team
- 7:48color and brick color. So brick color
- 7:51and color, they basically are the same
- 7:53property. Um, if you change this, then
- 7:55it changes the visual representation of
- 7:58the spawn location. But that's not going
- 8:00to be enough to actually make it
- 8:02functional to be the lime green spawn
- 8:04location team. We also need to go down
- 8:07here to change the team color property
- 8:09so that we know that this green team
- 8:12matches with this spawn location right
- 8:14here. So that's something important that
- 8:17you must do and to understand the
- 8:18difference of um but now if we go down
- 8:20here there's more properties that we can
- 8:22actually work with uh like force field
- 8:25duration allow team change on touch I
- 8:27believe that's what this is called and
- 8:29neutral. So, what I'm actually going to
- 8:31do is go back to our original spawn
- 8:33location, and I'm going to uncheck
- 8:34neutral. And I'm going to go back to
- 8:37this spawn location, and I'm going to
- 8:39uncheck neutral as well. Neutral
- 8:41basically means um if a spawn location
- 8:43is going to be the default spawn
- 8:45location that uh every player must spawn
- 8:48as uh whether they join into the game
- 8:50for the first time or if they reset
- 8:51their character. And since we now have
- 8:53teams, we don't want this to be the case
- 8:55because if we are now inside of the
- 8:57green team and we want to spawn inside
- 8:59of this one, then we need to uncheck
- 9:02neutral for both of them. And so now we
- 9:04have a basic setup going here. So if we
- 9:05hit play, then what should happen is
- 9:07we're automatically going to be put
- 9:09inside of the green team and we're going
- 9:11to spawn on top of the green team pad
- 9:13rather than this neutral pad right here.
- 9:16That doesn't serve any purpose other
- 9:17than uh bringing in neutral players
- 9:20inside of the game. So, if I reset my
- 9:22character, then I should still be able
- 9:24to spawn on top of this green uh spawn
- 9:27location rather than this one. So, it is
- 9:29basically working as expected. Now, what
- 9:31I'm going to do is duplicate this again
- 9:34and move it alongside this way. So, this
- 9:37one is going to be cyan instead of lime
- 9:39green. So, I'm going to change the brick
- 9:41color to cyan. And I'm going to go down
- 9:44here and change the team color to cyan
- 9:47as well. But this time what I'm going to
- 9:49do is check this property called allow
- 9:52team change on touch. So if we do this
- 9:55then what's going to happen is if we
- 9:57step on the spawn location then it's
- 9:59going to change our current team to this
- 10:02uh team instead. So if we hit play again
- 10:05then we should be spawning on top of the
- 10:07green spawn location. And so if I now
- 10:10touch this spawn location then it's
- 10:12going to change my team. It's going to
- 10:14say the chat that you are now on the
- 10:16blue team. um instead of the green team.
- 10:19So if I go and reset my character, then
- 10:21what should happen is I should be spawn
- 10:23on top of this spawn location rather
- 10:26than than this one. And because I don't
- 10:28have the allow team change on touch
- 10:30property enabled for this one, I can't
- 10:32go back to the green team. And so that's
- 10:34like additional functionality that I can
- 10:36introduce to you. But before we move on
- 10:38to the next thing, there's one more
- 10:40property here called force field
- 10:42duration. Now, basically what a force
- 10:44field is is if we spawn into the game or
- 10:48if we reset our character, there's a
- 10:50period of time where we are immune to
- 10:52any sort of damage whatsoever. And this
- 10:55is being represented through a visual
- 10:57force field that I'm actually going to
- 10:59show you. So, in order to do that, we
- 11:00need to change this duration property to
- 11:02something that's bigger than zero. So,
- 11:04in this case, let's make it uh five,
- 11:06let's say. So, let's now go into the
- 11:08game and hit play. And what should
- 11:10happen is if we join into the game, then
- 11:13there should be no no force field.
- 11:14That's because we have to go on the blue
- 11:16team and reset our character. So what we
- 11:18should see from this is a visual force
- 11:20field like this. We can't take any
- 11:22damage while we're inside of this force
- 11:24field. And then after 5 seconds, it's
- 11:26going to be destroyed. So that's
- 11:28basically a force field object that uh
- 11:31is contained within our character. And
- 11:33you can actually um utilize force fields
- 11:36inside of your own game if you want to.
- 11:38to let's say have a period of time where
- 11:40you don't want the player to be immune
- 11:42where you want the player to be immune
- 11:43to any damage. So that's like an
- 11:45additional thing right there. Okay. Now
- 11:47I want you to understand the difference
- 11:49between team and team color. So when
- 11:52we've been working with creating teams
- 11:54like on the right side we have the green
- 11:56team and the blue team. So the team
- 11:58itself is this team object right here.
- 12:01But the team color is simply just a
- 12:03brick color that is labeled as a team
- 12:06color property. Now, if you were to,
- 12:09let's say, utilize this inside of your
- 12:11Roblox game where you wanted to change a
- 12:13player's team to be this team, then you
- 12:16would basically just change the player's
- 12:18team to the green team. You wouldn't
- 12:20necessarily change the team color of the
- 12:22player with the team color of a
- 12:24different team. It's usually better to
- 12:26just change the team of the player to
- 12:30the team object that is contained inside
- 12:32of teams. And it can be confusing to use
- 12:35team color for your scripts if you're
- 12:38trying to change the team color of a
- 12:39player to a different team color versus
- 12:41if you were to change the team of a
- 12:43player to a specific team inside of
- 12:45teams. So I recommend changing the team
- 12:47of the player versus the team color of
- 12:50the player to a different one. So now
- 12:52I'm going to show you what this looks
- 12:53like through script. So I'm going to
- 12:54stop right here and what I'm going to do
- 12:57is go on the right side of server script
- 12:58service. I'm going to uh hit the plus
- 13:00sign and insert a script. So, what we're
- 13:03going to do first is make reference to
- 13:04the teams service. What we're going to
- 13:06do is say local teams equals game: get
- 13:10service teams. And it's just simply
- 13:12going to be this. And next thing we're
- 13:15going to do is let's say what we want to
- 13:16do for the script is manually change the
- 13:19team to the blue team as soon as we join
- 13:22into the game. So, what we're going to
- 13:23do is make reference to the blue team.
- 13:25We're going to say local blue team
- 13:29equals teams.blue blue team like this.
- 13:33So, as soon as we join into the game,
- 13:35what's going to happen is we're going to
- 13:36be set as the green team. But what we
- 13:39want to do is set the team to the blue
- 13:42team uh after like a little bit of time.
- 13:44So, what we can do is add a task.wait
- 13:46for about 2 seconds. And what we're
- 13:48going to do is make a player added
- 13:51event. So, what we're going to do is say
- 13:52game.players.player
- 13:54player added connect function open close
- 13:58parenthesis player
- 14:00and then we're going to hit enter. So
- 14:02I'm actually going to move taskweight
- 14:03down here inside of the player added
- 14:05event instead. So now what we're going
- 14:07to do is say player dot team equals blue
- 14:13team like this. So now if we go into the
- 14:16game and hit play, we should start in
- 14:18the green team. But then after about 2
- 14:20seconds, we should see that we have now
- 14:22manually been moved to the blue team
- 14:24from the script. And we did not change
- 14:26the team color, but instead we changed
- 14:28the team itself because it's generally a
- 14:30better practice to change the team
- 14:32versus the team color. We can implement
- 14:34a few basic things with teams now that
- 14:36we have this inside of our game. And the
- 14:38first one we can do is create a team
- 14:40only door, which should be pretty easy.
- 14:41So basically a door that opens up only
- 14:43if you are in a specific team that no
- 14:46other players in a different team can
- 14:48access. So what we can do is create a
- 14:51part inside of model. And I'm just going
- 14:52to scale this up just a little bit like
- 14:55this. And then I'm going to go down
- 14:57here, make anchored equal to true, and
- 15:00I'm now going to insert a script inside
- 15:02of this part like this. So the first
- 15:04thing we're going to do is make
- 15:05reference to the door. So we're going to
- 15:07say local door equals script.parent.
- 15:10And we're also going to make a debounce
- 15:12variable so that um we're not touching
- 15:15this door repeatedly. Uh we only need to
- 15:17touch it once uh before having a cool
- 15:19down. So what we're going to do is say
- 15:21local touched equals false. And then
- 15:24we're also going to um add a a door
- 15:28touched event by saying door.touched
- 15:31colon connect function open and close
- 15:33parenthesis hit. Uh and then we're going
- 15:36to say enter. And now what we're going
- 15:38to do is make reference to the humanoid.
- 15:39We're going to say local humanoid
- 15:43equals hit.
- 15:45Colon find first child open and close
- 15:48parenthesis humanoid. And then we're
- 15:50also going to locate if this is a
- 15:52player. So we're going to say local
- 15:54player equals game.players
- 15:58colon get player from character like
- 16:01this. And then we're going to pass the
- 16:02reference as hit.p parententar. And then
- 16:05we're going to check if humanoid exists
- 16:08and if the player exists and if touched
- 16:11is not true. So we're going to say and
- 16:14not touched. And finally we have to do
- 16:16one more check which is to see if the
- 16:19player's team is a specific team. So
- 16:21we're going to do is So what we're going
- 16:23to do is say player oh wait so what
- 16:25we're going to do is say and player.
- 16:28team equals and if we want to reference
- 16:32a specific team we can also do that
- 16:34directly inside of the teams folder
- 16:36inside of explorer. So what we can do is
- 16:38say game teams dot let's say blue team.
- 16:44Then we're going to hit enter. What
- 16:46we're going to do is say touched equals
- 16:49true. And then we're also going to add a
- 16:51taskw wait for about uh let's say 3
- 16:54seconds. And then we're going to say
- 16:55touched is back equal to false so that
- 16:57we can touch it again. And to make this
- 16:59door functional, what we're going to do
- 17:01is set the doors transparency equal to
- 17:050.5. So it's half transparent. And then
- 17:07we're also going to set the doors can
- 17:10collide equal to false so that players
- 17:12can walk through that door. So I'm going
- 17:15to copy this uh and then paste it down
- 17:17here. This is going to be set equal to
- 17:19zero. And then the canide is going to be
- 17:21set equal to true so that the door is
- 17:23back to its original state where you
- 17:25can't go through the door. So this is
- 17:27the basic setup of so this is basically
- 17:30how we create a team only door. So now
- 17:32if we go into the game, hit test and hit
- 17:34play. Then what should happen is we're
- 17:36going to be set to the blue team after
- 17:38about 2 seconds like this. So we should
- 17:40be able to access this door. So let's go
- 17:42through the door. And just like that we
- 17:44can access the door and we can go um
- 17:47back out the way we came from. So, if we
- 17:49were to go back to the script and change
- 17:51this to the green team, then we're not
- 17:54going to be able to go through the store
- 17:57because we're going to be on the blue
- 17:58team instead of the green team. So, as
- 18:00you can see, we cannot go through the
- 18:01store because we are not in the same
- 18:03team. Now, technically with this script,
- 18:05if you had one person who was inside of
- 18:08the green, if you had one person who was
- 18:10inside of the blue team that went
- 18:12through this door, then every single
- 18:14player behind him would be able to go
- 18:16through the store as well. So, you would
- 18:18have to utilize some sort of um local
- 18:20functionality onto this as well so that
- 18:22only that specific player can go through
- 18:24the door, but I'm not going to be
- 18:26implementing that inside of this
- 18:27episode. This is like a basic example
- 18:29that I can come up with uh when it comes
- 18:31to using teams inside of Roblox Studio.
- 18:33So, there's another good use case of
- 18:35using teams inside of Roblox Studio, and
- 18:38that is the ability to have friendly
- 18:41fire turned off. And basically what
- 18:42friendly fire is is if a if is if two
- 18:46players are in the same team, then they
- 18:48should pretty much not be able to kill
- 18:51each other or hurt each other. Um but
- 18:53instead they have the ability to hurt
- 18:55the other team if they were playing a
- 18:57competitive game of let's say sword
- 18:59fighting. I'm going to show you an
- 19:01example of this being used inside of
- 19:02Roblox's classic sword uh tool that is
- 19:05created by Roblox that you can find
- 19:06inside of the toolbox. So inside of the
- 19:09sword script, there should be this
- 19:11function here called is teammate that
- 19:14takes in two players. So player one and
- 19:15player two. So it's first going to check
- 19:17if player one and player two exists. And
- 19:20we're also going to check if player one
- 19:22is not in a neutral state and they are
- 19:26in a team. And then finally they check
- 19:29if the player one's team color is equal
- 19:31to the player two's team color. Now,
- 19:32what I would recommend is changing um
- 19:35the Now, what I would recommend is
- 19:37comparing the players team versus the
- 19:40players team color just because it's
- 19:41easier to distinguish from one another.
- 19:43But you could use either one of those
- 19:44two. I just recommend teams. And so,
- 19:46this function is being called down here
- 19:48by basically checking if the player that
- 19:50this player is trying to hit is a
- 19:52teammate, then we're just simply going
- 19:54to return this function and we're not
- 19:56going to make the humanoid and we're not
- 19:58going to make the player take damage
- 20:00because of it. And so that is a basic
- 20:02check you can do to see if you want to
- 20:06hit or if you want to hurt your own
- 20:08teammate, which in this case, we don't
- 20:09want to. So we determine that using
- 20:12their team color or team property. So
- 20:15for today's challenge, I want you to try
- 20:17and recreate this team selection system
- 20:20as soon as you join into the game for
- 20:22the first time. So basically, there's
- 20:24two options here. There's the green
- 20:25button, and then there's the blue button
- 20:27that represents the team that I can
- 20:29spawn into. So, right now I'm in the
- 20:30blue team, and if I select the green
- 20:32team, then it's going to get rid of the
- 20:35GUI for the selection, for the team
- 20:37selection. And it also placed me on top
- 20:39of the green team spawn location inside
- 20:41of the game. And this is pretty much
- 20:43done with, as you can see on the right
- 20:45side, I have a screen GUI, a local
- 20:46script, a frame with the two buttons,
- 20:49and I'm also using a remote and I'm also
- 20:52using a remote event to tell the server
- 20:54to change my players team if I do click
- 20:57on one of these buttons. So, uh, we're
- 20:59going to get into implementing in just a
- 21:01little bit, but I want you to try this
- 21:02for yourself first before we get into
- 21:04implementing this inside of Roblox
- 21:06Studio, at least just the scripts. So,
- 21:08try this out on your own first. And now,
- 21:10let's get into implementing. Okay, so
- 21:12what I have going on here is a screen
- 21:14GUI that has ignored GUI inset turned on
- 21:18so that there's not like some weird
- 21:20extra space on the top of the screen.
- 21:22And we also have a frame that basically
- 21:24covers the entire screen um with two
- 21:27buttons, blue and green. And so what I'm
- 21:29going to do now is create the scripts
- 21:31needed in order to make this functional.
- 21:33So I also made a remote event inside of
- 21:36replicated storage as well to represent
- 21:38the change team when we click on one of
- 21:40these buttons. So what I'm going to do
- 21:41first is insert a local script inside of
- 21:44the screen GUI. So I'm going to insert a
- 21:46local script like this. First thing I'm
- 21:47going to do is reference the GUI by
- 21:49saying local GUI equals script.parent.
- 21:53And then we're going to make reference
- 21:54to the two buttons. So we're going to
- 21:56say local green button equals
- 21:59gy.frame.green.
- 22:01And then we're going to make reference
- 22:03to the blue button by saying blue button
- 22:06equals GUI.frame.blue
- 22:08like this. And now we're going to create
- 22:10a mouse button oneclick event for each
- 22:12of these buttons. We're going to say
- 22:14green button dot mouse button oneclick
- 22:17connect function open and close
- 22:19parenthesis enter like this. And now
- 22:21what we're going to do is make reference
- 22:23to our change team remote event. So
- 22:27we're going to say local change team
- 22:30equals game.replicated storage colon
- 22:32wait for child and then change team just
- 22:35like this. So now what we're going to do
- 22:37is say change team colon fire server
- 22:41open and close parenthesis. And what
- 22:43we're going to pass into here is the
- 22:45name of the team that's inside of the
- 22:48team's um that's inside of our team's
- 22:51folder right here. So what we're going
- 22:52to do is in quotations we're going to
- 22:55say green team and make sure the name
- 22:57matches as well. Um, and another thing
- 23:00we're going to do is make the GUI
- 23:02disabled as soon as we press the button
- 23:04so that we we don't have to press it
- 23:06again. So, what we're going to do is say
- 23:08GUI enabled equals false. And one quick
- 23:12thing to note is make sure you have
- 23:14reset on spawn turned off. So, if we
- 23:17were to, let's say, reload our
- 23:18character, then it's not going to show
- 23:19the GUI again after that. So now what
- 23:21we're going to do is uh highlight all of
- 23:24this and then we're going to drop two
- 23:25lines and then we're going to replace
- 23:26this with the blue button and the string
- 23:30we're going to pass in is the blue team
- 23:33uh name. So now what we can do is go to
- 23:36the server script service insert another
- 23:38script. We're going to call this script
- 23:41um change team just like this. So, what
- 23:44we're going to do first is uh go back to
- 23:46our local script, make reference to the
- 23:48change team remote event by just copying
- 23:51this one line, pasting it like this. And
- 23:53now, what we're going to do is say
- 23:54change team.onervere
- 23:57event colon connect function
- 24:01open and close parenthesis. So, the
- 24:02first thing that's passed is always
- 24:04going to be the player. The next thing
- 24:06is going to be the name of the team,
- 24:08which is the first argument we passed.
- 24:09So, this is going to be the team name.
- 24:11We're going to hit enter like this. And
- 24:13so what we're now going to do is
- 24:15basically set the players team to the
- 24:18team name inside of teams. So what we're
- 24:22going to do is say local team equals
- 24:25game. teams colon find first child open
- 24:30close parenthesis team name. So if we
- 24:32got the right name for the team, whether
- 24:35that's the green team or the blue team,
- 24:36we're going to find it inside of here.
- 24:38Next, we're going to say if team then
- 24:42player team equals team. And it should
- 24:45basically be as simple as this. But
- 24:47another thing we want to do is rather
- 24:49than just setting the team to the new
- 24:52team, we also want to refresh the
- 24:55player's character so that they spawn on
- 24:56top of the spawn location. And there's a
- 24:58really easy command for this and that is
- 25:00going to be player colon load character.
- 25:05So basically um we are getting rid of
- 25:08the current character and we're
- 25:09resetting it. So they're respawning
- 25:12essentially. So that's what load
- 25:13character does. So they're going to
- 25:15respawn on top of the new spawn location
- 25:18associated with the with the new team
- 25:20that they're in. So that is the basic
- 25:22rundown of this uh team selection system
- 25:26that we have here. So, if we go hit
- 25:27test, hit play, then what we should see
- 25:29inside of the game is uh the the screen
- 25:33to show which team we want to be placed
- 25:35in. And if I hit blue team, then it's
- 25:38going to put me inside of the blue team,
- 25:39but I was already in the blue team. But
- 25:41it also refreshed my characters so that
- 25:43I can now spawn on top of this um spawn
- 25:46location. So, I hope this tutorial has
- 25:48given you some insight as to how you can
- 25:50implement teams inside of Roblox Studio.
- 25:52But if you want to learn another
- 25:54important concept that Roblox has that I
- 25:56think ties into teams is tools, which I
- 25:59will have for you right here. So go and
- 26:01watch that video right now. I hope you
- 26:03enjoyed this video and I will see you in
- 26:05the next one. Take care.
About this transcript
This page contains the full transcript of Teams - Roblox Advanced Scripting #27 by BrawlDev, generated from the public captions YouTube serves with the video. The transcript has 5,262 words across 695 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.