YouTube2Text

Teams - Roblox Advanced Scripting #27 — Transcript

by BrawlDev · 5,262 words · 695 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Oh, I'm about to make my shot. I'm wide
  2. 0:02open right now. All right, let's go. No,
  3. 0:05it's gonna hit the guy. No, I don't want
  4. 0:07it to hit the guy. Go in the goal. Go in
  5. 0:09the goal. In the goal. Oh my good. All
  6. 0:12right, go in. Go in. There we go. That
  7. 0:16is how you do a score. I am so good at
  8. 0:18this game. This video is going to be
  9. 0:21about teams, which is a feature that
  10. 0:22Roblox has provided to us that we are
  11. 0:25going to be using inside of this video.
  12. 0:27And I think it's important to understand
  13. 0:29why teams are useful to add inside of
  14. 0:32your Roblox game. But before we start
  15. 0:34implementing, let me show you um what
  16. 0:37teams are and how we can use them inside
  17. 0:39of our Roblox game. All right, let's
  18. 0:41think about this for a minute. Before we
  19. 0:43start adding teams inside of Roblox
  20. 0:45Studio, I I first want to briefly
  21. 0:47explain what teams actually are and how
  22. 0:49they serve a purpose for uh Roblox. So I
  23. 0:53hope you understand the basic idea of
  24. 0:55what a team is. A team is basically when
  25. 0:58you group a bunch of people together to
  26. 1:01achieve the same goal or a similar goal
  27. 1:04or you can also think of it as a faction
  28. 1:06as well among specific groups of people.
  29. 1:09So in this case with this soccer field
  30. 1:12here we have three players on this side
  31. 1:14and we have three players on this side.
  32. 1:16The goal for these three players that
  33. 1:18are grouped together is to move this
  34. 1:21ball towards this goal over here. And
  35. 1:23the goal for these players is to move
  36. 1:26this ball over to this goal. So each
  37. 1:28group of players or people have the same
  38. 1:32goal that they're trying to accomplish.
  39. 1:34And this can basically be said about any
  40. 1:37team or group of people trying to
  41. 1:39achieve the same goal um as a whole. So
  42. 1:42with that basic understanding of teams,
  43. 1:44Roblox has provided us a feature to
  44. 1:46allow us to add these teams inside of
  45. 1:49our games. So if we have teams, then we
  46. 1:51can differentiate these players from one
  47. 1:53another. So this ties back into Roblox
  48. 1:55because they actually have a built-in
  49. 1:57feature that allows us to add teams
  50. 2:00inside of our own game. And that's what
  51. 2:01I'm going to be showing you how to do
  52. 2:02inside of this video. So with that being
  53. 2:04said, let's now go ahead and go straight
  54. 2:06into implementing. Now that we
  55. 2:08understand it, let's implement teams
  56. 2:10inside of Roblox Studio. So, there's
  57. 2:12going to be a new service that I'm going
  58. 2:14to introduce to you inside of this video
  59. 2:16and it's also going to be live in the
  60. 2:19explorer and that ex and that is called
  61. 2:22teams. That's going to be down here. So,
  62. 2:24this is the service we're going to use
  63. 2:26to add teams to our own game. And the
  64. 2:28way we're going to do that is by going
  65. 2:29to the right side, hitting the plus
  66. 2:31sign, and we're going to insert a team
  67. 2:33like this. So now we have our first team
  68. 2:36inside of the team's uh folder inside of
  69. 2:39the explorer. So if we click on it, then
  70. 2:41there's a few properties here that we
  71. 2:42can work with that are unique to a team.
  72. 2:45So the first property is called auto
  73. 2:47assignable, which is basically a
  74. 2:49property that that tells Roblox if we
  75. 2:51want the player to automatically be
  76. 2:53assigned to this team if we join into
  77. 2:56the game. So I'm going to show you what
  78. 2:57that looks like right now. If we go to
  79. 2:59test and we go to play, then what we
  80. 3:01should see is Roblox is going to add us
  81. 3:03to the team. And the way we can see that
  82. 3:05is by going on the top right on our
  83. 3:08leaderboard. We can see that our
  84. 3:10username is placed right underneath the
  85. 3:13team that we just created. And so by
  86. 3:15default, it's this whiteish team with
  87. 3:18the name simply team. So we can
  88. 3:20customize this further uh if we go back
  89. 3:22into Roblox Studio. So let's hit stop.
  90. 3:24And what we can do is rename this team
  91. 3:27to something different. We can call this
  92. 3:30uh let's say green team like this. And
  93. 3:34the reason I'm going to say green team
  94. 3:35is because this is what's going to show
  95. 3:37the next property which is team color.
  96. 3:39And if we were to click on this team
  97. 3:40color, then we can pick any one of these
  98. 3:43colors to be the color of our team. So
  99. 3:46I'm just going to pick lime green for
  100. 3:47this example. So now what's going to
  101. 3:49happen is if we go into the game then we
  102. 3:51can see again on the top right of the
  103. 3:53screen that um our color of the color of
  104. 3:56the team changed and also the name of
  105. 3:59the team changed to green team. So that
  106. 4:01is basically what we wanted to see from
  107. 4:03here. Now another thing is if we add
  108. 4:06more teams. So if we let's say duplicate
  109. 4:08this. So, we're going to right click and
  110. 4:10duplicate it. And we call this one the
  111. 4:12blue team. And we change the team color
  112. 4:16to let's say um this color, cyan. If we
  113. 4:20go into the game again, hit play, then
  114. 4:22what's going to happen is Roblox is
  115. 4:24going to randomly put us either in the
  116. 4:26green team or the blue team. And now
  117. 4:28there's also two different teams inside
  118. 4:30of the the leaderboard because we've
  119. 4:32added multiple teams. And you can
  120. 4:33basically do this for as many teams as
  121. 4:35you want. I don't know if there's a
  122. 4:37limit to how many teams you can have
  123. 4:38inside of a Roblox game, but you can
  124. 4:40definitely have a lot of teams, that's
  125. 4:42for sure. Now, how does Roblox determine
  126. 4:44which team to put you in if we have
  127. 4:46multiple auto assignable properties
  128. 4:48checked since now we have green team and
  129. 4:50blue team checked? Well, basically what
  130. 4:52Roblox does is when we join into the
  131. 4:54game, Roblox is going to put us in the
  132. 4:57most convenient team first before
  133. 4:59putting us in the other team to make it
  134. 5:01balanced. So, what I'm talking about is
  135. 5:03if we join into the game, Roblox is most
  136. 5:06likely going to put us inside of the
  137. 5:07green team first if there's no players
  138. 5:09in there. But if there's one player
  139. 5:12inside of the green team and no players
  140. 5:14inside of the blue team, then Roblox is
  141. 5:16going to put me inside of the blue team
  142. 5:18as soon as I join into the game just to
  143. 5:20keep the teams balanced, if that makes
  144. 5:22sense. So, if I go into the game and I
  145. 5:24keep uh trying to refresh my character,
  146. 5:27then it's always going to put me inside
  147. 5:28of the green team. But if another player
  148. 5:30joined into the game, then they would
  149. 5:31probably be placed inside of the blue
  150. 5:33team instead just to keep the game
  151. 5:35balanced that way. Now, if you were to
  152. 5:37uncheck auto assignable for one of these
  153. 5:39teams, then Roblox will not put you
  154. 5:41inside of this team automatically if you
  155. 5:43join into the game. And it's going to be
  156. 5:45up to you as the developer to manually
  157. 5:48put these players inside of the blue
  158. 5:50team through scripting, which I'm going
  159. 5:52to show you how to do in just a little
  160. 5:53bit. But that's how you essentially add
  161. 5:56teams inside of Roblox Studio. Okay.
  162. 5:58Now, there's an interesting concept I
  163. 6:00want you to understand, and that is the
  164. 6:02use of spawn locations with teams. Now,
  165. 6:06I want you to understand this. Before I
  166. 6:08introduce teams to you, basically all
  167. 6:11players were inside of a neutral team or
  168. 6:13basically just no team at all. So, if we
  169. 6:16were to play the game, then all players
  170. 6:18were basically considered to be neutral
  171. 6:20because they were not tied to any
  172. 6:22specific team inside of the game. And
  173. 6:24because of this, we have what's called a
  174. 6:27spawn location here, which is
  175. 6:29essentially a part that allows players
  176. 6:31to spawn on top of when they join into
  177. 6:33the game or if they reset their
  178. 6:34character. So, this spawn location acts
  179. 6:37as a neutral spawn location where
  180. 6:39there's no team tied to it specifically.
  181. 6:42So, if we were to join into the game,
  182. 6:43we're always going to be spawning on
  183. 6:45this spawn location no matter what. But
  184. 6:47what's interesting is now that we have
  185. 6:48teams, we can have multiple different
  186. 6:51spawn locations that are specific to uh
  187. 6:55the teams that we've just created. So if
  188. 6:57a player was inside of the blue team and
  189. 7:01this was, let's say, the blue team's um
  190. 7:03spawn location, then all players that
  191. 7:05are in the blue team will respawn on
  192. 7:08this spawn location right here rather
  193. 7:10than this one or this one. And so right
  194. 7:13now I'm going to be showing you how to
  195. 7:14create different spawn locations for
  196. 7:17different teams. So what I'm going to do
  197. 7:19is take the spawn location and I'm going
  198. 7:21to hit Ctrl D to duplicate it and then
  199. 7:24I'm going to move it alongside this way.
  200. 7:26Now with this spawn location, what we
  201. 7:28can do is set a team for this specific
  202. 7:32spawn location. In this case, we can do
  203. 7:34the green team. So what I'm going to do
  204. 7:36is change the brick color to lime green.
  205. 7:38And I'm also going to scroll all the way
  206. 7:40down to this property called team color.
  207. 7:43And I'm going to change this to lime
  208. 7:45green. Now, it's very important to
  209. 7:46understand the difference between team
  210. 7:48color and brick color. So brick color
  211. 7:51and color, they basically are the same
  212. 7:53property. Um, if you change this, then
  213. 7:55it changes the visual representation of
  214. 7:58the spawn location. But that's not going
  215. 8:00to be enough to actually make it
  216. 8:02functional to be the lime green spawn
  217. 8:04location team. We also need to go down
  218. 8:07here to change the team color property
  219. 8:09so that we know that this green team
  220. 8:12matches with this spawn location right
  221. 8:14here. So that's something important that
  222. 8:17you must do and to understand the
  223. 8:18difference of um but now if we go down
  224. 8:20here there's more properties that we can
  225. 8:22actually work with uh like force field
  226. 8:25duration allow team change on touch I
  227. 8:27believe that's what this is called and
  228. 8:29neutral. So, what I'm actually going to
  229. 8:31do is go back to our original spawn
  230. 8:33location, and I'm going to uncheck
  231. 8:34neutral. And I'm going to go back to
  232. 8:37this spawn location, and I'm going to
  233. 8:39uncheck neutral as well. Neutral
  234. 8:41basically means um if a spawn location
  235. 8:43is going to be the default spawn
  236. 8:45location that uh every player must spawn
  237. 8:48as uh whether they join into the game
  238. 8:50for the first time or if they reset
  239. 8:51their character. And since we now have
  240. 8:53teams, we don't want this to be the case
  241. 8:55because if we are now inside of the
  242. 8:57green team and we want to spawn inside
  243. 8:59of this one, then we need to uncheck
  244. 9:02neutral for both of them. And so now we
  245. 9:04have a basic setup going here. So if we
  246. 9:05hit play, then what should happen is
  247. 9:07we're automatically going to be put
  248. 9:09inside of the green team and we're going
  249. 9:11to spawn on top of the green team pad
  250. 9:13rather than this neutral pad right here.
  251. 9:16That doesn't serve any purpose other
  252. 9:17than uh bringing in neutral players
  253. 9:20inside of the game. So, if I reset my
  254. 9:22character, then I should still be able
  255. 9:24to spawn on top of this green uh spawn
  256. 9:27location rather than this one. So, it is
  257. 9:29basically working as expected. Now, what
  258. 9:31I'm going to do is duplicate this again
  259. 9:34and move it alongside this way. So, this
  260. 9:37one is going to be cyan instead of lime
  261. 9:39green. So, I'm going to change the brick
  262. 9:41color to cyan. And I'm going to go down
  263. 9:44here and change the team color to cyan
  264. 9:47as well. But this time what I'm going to
  265. 9:49do is check this property called allow
  266. 9:52team change on touch. So if we do this
  267. 9:55then what's going to happen is if we
  268. 9:57step on the spawn location then it's
  269. 9:59going to change our current team to this
  270. 10:02uh team instead. So if we hit play again
  271. 10:05then we should be spawning on top of the
  272. 10:07green spawn location. And so if I now
  273. 10:10touch this spawn location then it's
  274. 10:12going to change my team. It's going to
  275. 10:14say the chat that you are now on the
  276. 10:16blue team. um instead of the green team.
  277. 10:19So if I go and reset my character, then
  278. 10:21what should happen is I should be spawn
  279. 10:23on top of this spawn location rather
  280. 10:26than than this one. And because I don't
  281. 10:28have the allow team change on touch
  282. 10:30property enabled for this one, I can't
  283. 10:32go back to the green team. And so that's
  284. 10:34like additional functionality that I can
  285. 10:36introduce to you. But before we move on
  286. 10:38to the next thing, there's one more
  287. 10:40property here called force field
  288. 10:42duration. Now, basically what a force
  289. 10:44field is is if we spawn into the game or
  290. 10:48if we reset our character, there's a
  291. 10:50period of time where we are immune to
  292. 10:52any sort of damage whatsoever. And this
  293. 10:55is being represented through a visual
  294. 10:57force field that I'm actually going to
  295. 10:59show you. So, in order to do that, we
  296. 11:00need to change this duration property to
  297. 11:02something that's bigger than zero. So,
  298. 11:04in this case, let's make it uh five,
  299. 11:06let's say. So, let's now go into the
  300. 11:08game and hit play. And what should
  301. 11:10happen is if we join into the game, then
  302. 11:13there should be no no force field.
  303. 11:14That's because we have to go on the blue
  304. 11:16team and reset our character. So what we
  305. 11:18should see from this is a visual force
  306. 11:20field like this. We can't take any
  307. 11:22damage while we're inside of this force
  308. 11:24field. And then after 5 seconds, it's
  309. 11:26going to be destroyed. So that's
  310. 11:28basically a force field object that uh
  311. 11:31is contained within our character. And
  312. 11:33you can actually um utilize force fields
  313. 11:36inside of your own game if you want to.
  314. 11:38to let's say have a period of time where
  315. 11:40you don't want the player to be immune
  316. 11:42where you want the player to be immune
  317. 11:43to any damage. So that's like an
  318. 11:45additional thing right there. Okay. Now
  319. 11:47I want you to understand the difference
  320. 11:49between team and team color. So when
  321. 11:52we've been working with creating teams
  322. 11:54like on the right side we have the green
  323. 11:56team and the blue team. So the team
  324. 11:58itself is this team object right here.
  325. 12:01But the team color is simply just a
  326. 12:03brick color that is labeled as a team
  327. 12:06color property. Now, if you were to,
  328. 12:09let's say, utilize this inside of your
  329. 12:11Roblox game where you wanted to change a
  330. 12:13player's team to be this team, then you
  331. 12:16would basically just change the player's
  332. 12:18team to the green team. You wouldn't
  333. 12:20necessarily change the team color of the
  334. 12:22player with the team color of a
  335. 12:24different team. It's usually better to
  336. 12:26just change the team of the player to
  337. 12:30the team object that is contained inside
  338. 12:32of teams. And it can be confusing to use
  339. 12:35team color for your scripts if you're
  340. 12:38trying to change the team color of a
  341. 12:39player to a different team color versus
  342. 12:41if you were to change the team of a
  343. 12:43player to a specific team inside of
  344. 12:45teams. So I recommend changing the team
  345. 12:47of the player versus the team color of
  346. 12:50the player to a different one. So now
  347. 12:52I'm going to show you what this looks
  348. 12:53like through script. So I'm going to
  349. 12:54stop right here and what I'm going to do
  350. 12:57is go on the right side of server script
  351. 12:58service. I'm going to uh hit the plus
  352. 13:00sign and insert a script. So, what we're
  353. 13:03going to do first is make reference to
  354. 13:04the teams service. What we're going to
  355. 13:06do is say local teams equals game: get
  356. 13:10service teams. And it's just simply
  357. 13:12going to be this. And next thing we're
  358. 13:15going to do is let's say what we want to
  359. 13:16do for the script is manually change the
  360. 13:19team to the blue team as soon as we join
  361. 13:22into the game. So, what we're going to
  362. 13:23do is make reference to the blue team.
  363. 13:25We're going to say local blue team
  364. 13:29equals teams.blue blue team like this.
  365. 13:33So, as soon as we join into the game,
  366. 13:35what's going to happen is we're going to
  367. 13:36be set as the green team. But what we
  368. 13:39want to do is set the team to the blue
  369. 13:42team uh after like a little bit of time.
  370. 13:44So, what we can do is add a task.wait
  371. 13:46for about 2 seconds. And what we're
  372. 13:48going to do is make a player added
  373. 13:51event. So, what we're going to do is say
  374. 13:52game.players.player
  375. 13:54player added connect function open close
  376. 13:58parenthesis player
  377. 14:00and then we're going to hit enter. So
  378. 14:02I'm actually going to move taskweight
  379. 14:03down here inside of the player added
  380. 14:05event instead. So now what we're going
  381. 14:07to do is say player dot team equals blue
  382. 14:13team like this. So now if we go into the
  383. 14:16game and hit play, we should start in
  384. 14:18the green team. But then after about 2
  385. 14:20seconds, we should see that we have now
  386. 14:22manually been moved to the blue team
  387. 14:24from the script. And we did not change
  388. 14:26the team color, but instead we changed
  389. 14:28the team itself because it's generally a
  390. 14:30better practice to change the team
  391. 14:32versus the team color. We can implement
  392. 14:34a few basic things with teams now that
  393. 14:36we have this inside of our game. And the
  394. 14:38first one we can do is create a team
  395. 14:40only door, which should be pretty easy.
  396. 14:41So basically a door that opens up only
  397. 14:43if you are in a specific team that no
  398. 14:46other players in a different team can
  399. 14:48access. So what we can do is create a
  400. 14:51part inside of model. And I'm just going
  401. 14:52to scale this up just a little bit like
  402. 14:55this. And then I'm going to go down
  403. 14:57here, make anchored equal to true, and
  404. 15:00I'm now going to insert a script inside
  405. 15:02of this part like this. So the first
  406. 15:04thing we're going to do is make
  407. 15:05reference to the door. So we're going to
  408. 15:07say local door equals script.parent.
  409. 15:10And we're also going to make a debounce
  410. 15:12variable so that um we're not touching
  411. 15:15this door repeatedly. Uh we only need to
  412. 15:17touch it once uh before having a cool
  413. 15:19down. So what we're going to do is say
  414. 15:21local touched equals false. And then
  415. 15:24we're also going to um add a a door
  416. 15:28touched event by saying door.touched
  417. 15:31colon connect function open and close
  418. 15:33parenthesis hit. Uh and then we're going
  419. 15:36to say enter. And now what we're going
  420. 15:38to do is make reference to the humanoid.
  421. 15:39We're going to say local humanoid
  422. 15:43equals hit.
  423. 15:45Colon find first child open and close
  424. 15:48parenthesis humanoid. And then we're
  425. 15:50also going to locate if this is a
  426. 15:52player. So we're going to say local
  427. 15:54player equals game.players
  428. 15:58colon get player from character like
  429. 16:01this. And then we're going to pass the
  430. 16:02reference as hit.p parententar. And then
  431. 16:05we're going to check if humanoid exists
  432. 16:08and if the player exists and if touched
  433. 16:11is not true. So we're going to say and
  434. 16:14not touched. And finally we have to do
  435. 16:16one more check which is to see if the
  436. 16:19player's team is a specific team. So
  437. 16:21we're going to do is So what we're going
  438. 16:23to do is say player oh wait so what
  439. 16:25we're going to do is say and player.
  440. 16:28team equals and if we want to reference
  441. 16:32a specific team we can also do that
  442. 16:34directly inside of the teams folder
  443. 16:36inside of explorer. So what we can do is
  444. 16:38say game teams dot let's say blue team.
  445. 16:44Then we're going to hit enter. What
  446. 16:46we're going to do is say touched equals
  447. 16:49true. And then we're also going to add a
  448. 16:51taskw wait for about uh let's say 3
  449. 16:54seconds. And then we're going to say
  450. 16:55touched is back equal to false so that
  451. 16:57we can touch it again. And to make this
  452. 16:59door functional, what we're going to do
  453. 17:01is set the doors transparency equal to
  454. 17:050.5. So it's half transparent. And then
  455. 17:07we're also going to set the doors can
  456. 17:10collide equal to false so that players
  457. 17:12can walk through that door. So I'm going
  458. 17:15to copy this uh and then paste it down
  459. 17:17here. This is going to be set equal to
  460. 17:19zero. And then the canide is going to be
  461. 17:21set equal to true so that the door is
  462. 17:23back to its original state where you
  463. 17:25can't go through the door. So this is
  464. 17:27the basic setup of so this is basically
  465. 17:30how we create a team only door. So now
  466. 17:32if we go into the game, hit test and hit
  467. 17:34play. Then what should happen is we're
  468. 17:36going to be set to the blue team after
  469. 17:38about 2 seconds like this. So we should
  470. 17:40be able to access this door. So let's go
  471. 17:42through the door. And just like that we
  472. 17:44can access the door and we can go um
  473. 17:47back out the way we came from. So, if we
  474. 17:49were to go back to the script and change
  475. 17:51this to the green team, then we're not
  476. 17:54going to be able to go through the store
  477. 17:57because we're going to be on the blue
  478. 17:58team instead of the green team. So, as
  479. 18:00you can see, we cannot go through the
  480. 18:01store because we are not in the same
  481. 18:03team. Now, technically with this script,
  482. 18:05if you had one person who was inside of
  483. 18:08the green, if you had one person who was
  484. 18:10inside of the blue team that went
  485. 18:12through this door, then every single
  486. 18:14player behind him would be able to go
  487. 18:16through the store as well. So, you would
  488. 18:18have to utilize some sort of um local
  489. 18:20functionality onto this as well so that
  490. 18:22only that specific player can go through
  491. 18:24the door, but I'm not going to be
  492. 18:26implementing that inside of this
  493. 18:27episode. This is like a basic example
  494. 18:29that I can come up with uh when it comes
  495. 18:31to using teams inside of Roblox Studio.
  496. 18:33So, there's another good use case of
  497. 18:35using teams inside of Roblox Studio, and
  498. 18:38that is the ability to have friendly
  499. 18:41fire turned off. And basically what
  500. 18:42friendly fire is is if a if is if two
  501. 18:46players are in the same team, then they
  502. 18:48should pretty much not be able to kill
  503. 18:51each other or hurt each other. Um but
  504. 18:53instead they have the ability to hurt
  505. 18:55the other team if they were playing a
  506. 18:57competitive game of let's say sword
  507. 18:59fighting. I'm going to show you an
  508. 19:01example of this being used inside of
  509. 19:02Roblox's classic sword uh tool that is
  510. 19:05created by Roblox that you can find
  511. 19:06inside of the toolbox. So inside of the
  512. 19:09sword script, there should be this
  513. 19:11function here called is teammate that
  514. 19:14takes in two players. So player one and
  515. 19:15player two. So it's first going to check
  516. 19:17if player one and player two exists. And
  517. 19:20we're also going to check if player one
  518. 19:22is not in a neutral state and they are
  519. 19:26in a team. And then finally they check
  520. 19:29if the player one's team color is equal
  521. 19:31to the player two's team color. Now,
  522. 19:32what I would recommend is changing um
  523. 19:35the Now, what I would recommend is
  524. 19:37comparing the players team versus the
  525. 19:40players team color just because it's
  526. 19:41easier to distinguish from one another.
  527. 19:43But you could use either one of those
  528. 19:44two. I just recommend teams. And so,
  529. 19:46this function is being called down here
  530. 19:48by basically checking if the player that
  531. 19:50this player is trying to hit is a
  532. 19:52teammate, then we're just simply going
  533. 19:54to return this function and we're not
  534. 19:56going to make the humanoid and we're not
  535. 19:58going to make the player take damage
  536. 20:00because of it. And so that is a basic
  537. 20:02check you can do to see if you want to
  538. 20:06hit or if you want to hurt your own
  539. 20:08teammate, which in this case, we don't
  540. 20:09want to. So we determine that using
  541. 20:12their team color or team property. So
  542. 20:15for today's challenge, I want you to try
  543. 20:17and recreate this team selection system
  544. 20:20as soon as you join into the game for
  545. 20:22the first time. So basically, there's
  546. 20:24two options here. There's the green
  547. 20:25button, and then there's the blue button
  548. 20:27that represents the team that I can
  549. 20:29spawn into. So, right now I'm in the
  550. 20:30blue team, and if I select the green
  551. 20:32team, then it's going to get rid of the
  552. 20:35GUI for the selection, for the team
  553. 20:37selection. And it also placed me on top
  554. 20:39of the green team spawn location inside
  555. 20:41of the game. And this is pretty much
  556. 20:43done with, as you can see on the right
  557. 20:45side, I have a screen GUI, a local
  558. 20:46script, a frame with the two buttons,
  559. 20:49and I'm also using a remote and I'm also
  560. 20:52using a remote event to tell the server
  561. 20:54to change my players team if I do click
  562. 20:57on one of these buttons. So, uh, we're
  563. 20:59going to get into implementing in just a
  564. 21:01little bit, but I want you to try this
  565. 21:02for yourself first before we get into
  566. 21:04implementing this inside of Roblox
  567. 21:06Studio, at least just the scripts. So,
  568. 21:08try this out on your own first. And now,
  569. 21:10let's get into implementing. Okay, so
  570. 21:12what I have going on here is a screen
  571. 21:14GUI that has ignored GUI inset turned on
  572. 21:18so that there's not like some weird
  573. 21:20extra space on the top of the screen.
  574. 21:22And we also have a frame that basically
  575. 21:24covers the entire screen um with two
  576. 21:27buttons, blue and green. And so what I'm
  577. 21:29going to do now is create the scripts
  578. 21:31needed in order to make this functional.
  579. 21:33So I also made a remote event inside of
  580. 21:36replicated storage as well to represent
  581. 21:38the change team when we click on one of
  582. 21:40these buttons. So what I'm going to do
  583. 21:41first is insert a local script inside of
  584. 21:44the screen GUI. So I'm going to insert a
  585. 21:46local script like this. First thing I'm
  586. 21:47going to do is reference the GUI by
  587. 21:49saying local GUI equals script.parent.
  588. 21:53And then we're going to make reference
  589. 21:54to the two buttons. So we're going to
  590. 21:56say local green button equals
  591. 21:59gy.frame.green.
  592. 22:01And then we're going to make reference
  593. 22:03to the blue button by saying blue button
  594. 22:06equals GUI.frame.blue
  595. 22:08like this. And now we're going to create
  596. 22:10a mouse button oneclick event for each
  597. 22:12of these buttons. We're going to say
  598. 22:14green button dot mouse button oneclick
  599. 22:17connect function open and close
  600. 22:19parenthesis enter like this. And now
  601. 22:21what we're going to do is make reference
  602. 22:23to our change team remote event. So
  603. 22:27we're going to say local change team
  604. 22:30equals game.replicated storage colon
  605. 22:32wait for child and then change team just
  606. 22:35like this. So now what we're going to do
  607. 22:37is say change team colon fire server
  608. 22:41open and close parenthesis. And what
  609. 22:43we're going to pass into here is the
  610. 22:45name of the team that's inside of the
  611. 22:48team's um that's inside of our team's
  612. 22:51folder right here. So what we're going
  613. 22:52to do is in quotations we're going to
  614. 22:55say green team and make sure the name
  615. 22:57matches as well. Um, and another thing
  616. 23:00we're going to do is make the GUI
  617. 23:02disabled as soon as we press the button
  618. 23:04so that we we don't have to press it
  619. 23:06again. So, what we're going to do is say
  620. 23:08GUI enabled equals false. And one quick
  621. 23:12thing to note is make sure you have
  622. 23:14reset on spawn turned off. So, if we
  623. 23:17were to, let's say, reload our
  624. 23:18character, then it's not going to show
  625. 23:19the GUI again after that. So now what
  626. 23:21we're going to do is uh highlight all of
  627. 23:24this and then we're going to drop two
  628. 23:25lines and then we're going to replace
  629. 23:26this with the blue button and the string
  630. 23:30we're going to pass in is the blue team
  631. 23:33uh name. So now what we can do is go to
  632. 23:36the server script service insert another
  633. 23:38script. We're going to call this script
  634. 23:41um change team just like this. So, what
  635. 23:44we're going to do first is uh go back to
  636. 23:46our local script, make reference to the
  637. 23:48change team remote event by just copying
  638. 23:51this one line, pasting it like this. And
  639. 23:53now, what we're going to do is say
  640. 23:54change team.onervere
  641. 23:57event colon connect function
  642. 24:01open and close parenthesis. So, the
  643. 24:02first thing that's passed is always
  644. 24:04going to be the player. The next thing
  645. 24:06is going to be the name of the team,
  646. 24:08which is the first argument we passed.
  647. 24:09So, this is going to be the team name.
  648. 24:11We're going to hit enter like this. And
  649. 24:13so what we're now going to do is
  650. 24:15basically set the players team to the
  651. 24:18team name inside of teams. So what we're
  652. 24:22going to do is say local team equals
  653. 24:25game. teams colon find first child open
  654. 24:30close parenthesis team name. So if we
  655. 24:32got the right name for the team, whether
  656. 24:35that's the green team or the blue team,
  657. 24:36we're going to find it inside of here.
  658. 24:38Next, we're going to say if team then
  659. 24:42player team equals team. And it should
  660. 24:45basically be as simple as this. But
  661. 24:47another thing we want to do is rather
  662. 24:49than just setting the team to the new
  663. 24:52team, we also want to refresh the
  664. 24:55player's character so that they spawn on
  665. 24:56top of the spawn location. And there's a
  666. 24:58really easy command for this and that is
  667. 25:00going to be player colon load character.
  668. 25:05So basically um we are getting rid of
  669. 25:08the current character and we're
  670. 25:09resetting it. So they're respawning
  671. 25:12essentially. So that's what load
  672. 25:13character does. So they're going to
  673. 25:15respawn on top of the new spawn location
  674. 25:18associated with the with the new team
  675. 25:20that they're in. So that is the basic
  676. 25:22rundown of this uh team selection system
  677. 25:26that we have here. So, if we go hit
  678. 25:27test, hit play, then what we should see
  679. 25:29inside of the game is uh the the screen
  680. 25:33to show which team we want to be placed
  681. 25:35in. And if I hit blue team, then it's
  682. 25:38going to put me inside of the blue team,
  683. 25:39but I was already in the blue team. But
  684. 25:41it also refreshed my characters so that
  685. 25:43I can now spawn on top of this um spawn
  686. 25:46location. So, I hope this tutorial has
  687. 25:48given you some insight as to how you can
  688. 25:50implement teams inside of Roblox Studio.
  689. 25:52But if you want to learn another
  690. 25:54important concept that Roblox has that I
  691. 25:56think ties into teams is tools, which I
  692. 25:59will have for you right here. So go and
  693. 26:01watch that video right now. I hope you
  694. 26:03enjoyed this video and I will see you in
  695. 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.