YouTube2Text

[Part5.5] Roblox Combat System for Beginners | Collision Groups & Minor Fixes — Transcript

by Senko · 2,914 words · 471 segments · language en · Watch on YouTube

Full transcript

  1. 0:00All right, today's going to be sort of
  2. 0:02episode 5.5. It's also going to be a
  3. 0:05double upload day, but for 5.5, I'm
  4. 0:08going to be just doing some minor
  5. 0:10additions and sort
  6. 0:11of fixes to the comment system we
  7. 0:14already have. So,
  8. 0:18yeah. Right.
  9. 0:21The first thing I'm going to do is I'm
  10. 0:23going to add collision groups to the
  11. 0:25game, which what those are is that they
  12. 0:28allow certain objects to collide with
  13. 0:31each other and not collide with each
  14. 0:33other. So, for example, you'll see that
  15. 0:35the car my character can sort of collide
  16. 0:37with these
  17. 0:38dummies, which could pose a problem in
  18. 0:41the
  19. 0:42future for flinging and things like that
  20. 0:45because if something accidentally
  21. 0:47happens and I touch the the dummy with a
  22. 0:51great greater amount of force, then I
  23. 0:52could get flung on
  24. 0:56accident. So, a way to avoid that is by
  25. 0:58adding collision groups.
  26. 1:01So if I go to model and collision
  27. 1:05groups, I can add a group called
  28. 1:09players like so. And so we can say
  29. 1:12players. We don't want the players to
  30. 1:14collide with other players. So we can
  31. 1:15check that off.
  32. 1:18Now we want to add these
  33. 1:21um these dummies to the collision group.
  34. 1:26So we can make a script in server script
  35. 1:28service called
  36. 1:31collision handle like so.
  37. 1:34You can just name this anything you
  38. 1:35want, but I'm just going to call this
  39. 1:36collision handle.
  40. 1:38And another thing in addition with the
  41. 1:41collision groups is I want to add sort
  42. 1:43of an I want to organize the workspace a
  43. 1:46little bit. So, we can add a folder here
  44. 1:48called
  45. 1:50world. And I can move all of these
  46. 1:55dummies to the world. And we'll add
  47. 1:58another folder here called live. So this
  48. 2:00handles this folder just contains all
  49. 2:02the live things like my player, other
  50. 2:05players, and
  51. 2:06dummies. So we can add that
  52. 2:09there. And we can also add a folder
  53. 2:11called
  54. 2:13hitboxes and effects like so.
  55. 2:19Now
  56. 2:21since we did that, now we need to go to
  57. 2:23our weapon, our fist weapon, and we need
  58. 2:26to change the place where we parent the
  59. 2:28hitbox clone to workspace.orld to hit
  60. 2:31boxes and change our overlap params
  61. 2:35too. Like
  62. 2:38so. So now if we were to play the game
  63. 2:44and punch,
  64. 2:46you'll see that the hitbox gets parented
  65. 2:48to the hitbox folder in here.
  66. 2:51I can open this quick enough. There we
  67. 2:52go. Like so.
  68. 2:56Now, we also want to parent the player
  69. 2:59to live or the character to live as well
  70. 3:01because you see we're still in the
  71. 3:03workspace um folder, not this folder. So
  72. 3:08to do that, we can go over
  73. 3:10here and we can start initializing our
  74. 3:16variables. So we're going to do a player
  75. 3:18character added function like
  76. 3:20so. And we can say if player character
  77. 3:24then and we can add a function down
  78. 3:27here, a method called character
  79. 3:31added. So the reason we do both of these
  80. 3:34is because this checks if the player or
  81. 3:37the character is already there.
  82. 3:40Let's say the character is not there and
  83. 3:41they need to load. So this checks for
  84. 3:43when the character
  85. 3:45loads. So that's why we do that. And now
  86. 3:48we can also add a function called
  87. 3:49character
  88. 3:51added. So you see in the character added
  89. 3:53function there's automatically a
  90. 3:55parameter passed that Roblox gives you
  91. 3:58called character. So because of that we
  92. 4:00can remove the function part right here
  93. 4:02and just say character added.
  94. 4:05Now we can also do character add right
  95. 4:07here.
  96. 4:09And then we can get run
  97. 4:12service and we want to wait just a
  98. 4:15slight second
  99. 4:16before it parents it parents the
  100. 4:19character. So we'll do heartbeat wait
  101. 4:21and we can parent the character to
  102. 4:23workspace.world.live like
  103. 4:26so. So if we play the game
  104. 4:31You'll see that the character isn't
  105. 4:32paired to the workspace anymore, but
  106. 4:34he's in live and everything still works
  107. 4:36as normal. This is just how most games
  108. 4:39organize their workspace.
  109. 4:46All right. Now, we'll add collision
  110. 4:47groups to the character and the dummies.
  111. 4:51So if you recall earlier, we already
  112. 4:53made the collision groups in here. But
  113. 4:55now we need to apply them to everything
  114. 4:57that's related to the player or a
  115. 4:59character model.
  116. 5:02So we can say for underscore,
  117. 5:06uh v character get descendants do like
  118. 5:10so. And we let's annotate this because
  119. 5:12we know it's going to be a model. So we
  120. 5:13can say get
  121. 5:15descendants. Oops. There we go.
  122. 5:18We can say if V is a base part
  123. 5:22or V is a mesh part
  124. 5:27or V is a union operation. So we want to
  125. 5:30want to make sure to check for every
  126. 5:32possible thing that could have collision
  127. 5:34group in it. So I'm going to say v.c
  128. 5:36collision group is equal to players like
  129. 5:37so.
  130. 5:41So if we play the game
  131. 5:45and we open our player
  132. 5:48Let me click on anything. You can see
  133. 5:50that our collision group is players.
  134. 5:55And we also need to make sure that this
  135. 5:57is also set to players too. So we'll say
  136. 6:00if V is a part or V is a part.
  137. 6:05Then
  138. 6:10so now if we play we'll see that
  139. 6:12everything in our character is set
  140. 6:15to players.
  141. 6:21Like
  142. 6:22so. And for this we don't we we can
  143. 6:25ignore the uh this part not being set to
  144. 6:28players because the hand collide is
  145. 6:29already off for this. So that'll be
  146. 6:32fine because it won't collide with it.
  147. 6:35Anyways, now since we made this players,
  148. 6:38we also need to make the dummies
  149. 6:40collision players too cuz this is
  150. 6:42already set to default. So one way we
  151. 6:44could do this is just change this to
  152. 6:46players, which is going to take an
  153. 6:48extremely long time. Or another way we
  154. 6:50can do this is
  155. 6:52say underscore, player.
  156. 6:57And well before we do that I'm just
  157. 6:59going to add a character added to
  158. 7:02this we can say if player character
  159. 7:07then let's not let's do not repeat
  160. 7:10yourself um principle. So we can say
  161. 7:12local function handle character
  162. 7:15added player like so. Now we can just
  163. 7:18copy and paste that in there and then we
  164. 7:20can say handle character
  165. 7:23added. We also say handle cur
  166. 7:26here. So the reason we do this is
  167. 7:29because let's say a player is already in
  168. 7:31the game and this um method doesn't
  169. 7:34call. So we can check it twice to make
  170. 7:36sure that it ensures that the character
  171. 7:38gets parented and things like
  172. 7:40that. And now we can handle the
  173. 7:43collision groups
  174. 7:44for
  175. 7:47non-players. So we can say for
  176. 7:50underscore, vin workspace.world.live
  177. 7:53live get children
  178. 7:55do if if not players get player from
  179. 7:59character V. So it's checking if it's a
  180. 8:01player or not if the character can
  181. 8:03correspond to a player in the game. So
  182. 8:05if it isn't then we can just do
  183. 8:09this like so.
  184. 8:16Now we can make a function here called
  185. 8:19let's
  186. 8:20see call local function um uh handle
  187. 8:25collision
  188. 8:27groups like so and we can call this
  189. 8:30character and that's going to handle
  190. 8:32that handle collision groups
  191. 8:35character and in here we can also say
  192. 8:38handle collision
  193. 8:41groups V which V in this case is the
  194. 8:44character model or the dummies
  195. 8:48model. So now if we play the game, we
  196. 8:51get an error. Okay, let's see what this
  197. 8:54is. Attempt to an external character.
  198. 8:57Ah, we didn't pass the parameters in
  199. 8:59here. Okay, now we just add in player
  200. 9:01here and player here and we should be
  201. 9:03fine.
  202. 9:07Let's see what else. If player character
  203. 9:12handle character
  204. 9:13added. Here we go.
  205. 9:16Instead of doing this, we need to say
  206. 9:18handle closing groups and V.
  207. 9:24Here we go. Now, if we play the game,
  208. 9:26we'll see that
  209. 9:29all these are set to player. And now we
  210. 9:31we can't collide with these. However, we
  211. 9:33can still punch these
  212. 9:35things. Still punch the dummies, but we
  213. 9:37can't collide with
  214. 9:38them. So, once again, this will just
  215. 9:41prevent flinging and unintended things
  216. 9:43like that.
  217. 9:47Now, next up is we're just going
  218. 9:49to make it to where you can't attack or
  219. 9:52do any actions when you die, cuz we
  220. 9:55don't want that occurring in the game,
  221. 9:57obviously.
  222. 9:59So, and here we can say, let's see,
  223. 10:07right? We can make a function
  224. 10:11called is dead. So we say local function
  225. 10:15is actually no we don't need to do that.
  226. 10:18We can go to our collision handler
  227. 10:22and we can let's rename this or we can
  228. 10:25go to combat service here. There we go.
  229. 10:26Combat system.
  230. 10:28And now we can also check for when the
  231. 10:30character is
  232. 10:32added.
  233. 10:33So go down here and we can or we can go
  234. 10:36right here players. Player addit connect
  235. 10:39function player
  236. 10:42or underscore comma player and players
  237. 10:44get player do.
  238. 10:48Now we can say character added
  239. 10:56player character then handle character
  240. 11:00added
  241. 11:01[Music]
  242. 11:03character and
  243. 11:09Let's just copy this.
  244. 11:12All right.
  245. 11:14Now in here we can say local status
  246. 11:16folder equals character wait for child
  247. 11:19status
  248. 11:21commu. We to wait for child because what
  249. 11:23if the the status folder hasn't actually
  250. 11:26loaded in yet. We wait for child because
  251. 11:28we know it's going to be there but we
  252. 11:29don't know when it's going to be there.
  253. 11:31So this is going to work. Now we can say
  254. 11:33local
  255. 11:34humanoid equals character reference
  256. 11:36child
  257. 11:37humanoid and then we can say humanoid
  258. 11:41died connect function. So he's only
  259. 11:43going to die once. So we can just say
  260. 11:45once like so and we can say state
  261. 11:48service which we have up
  262. 11:50here. Add
  263. 11:52state character, dead like
  264. 11:56so. Now this will handle that.
  265. 12:01Now, if we play the game,
  266. 12:05we will see that whenever the character
  267. 12:07dies, there's going to be a folder added
  268. 12:09to say called died or
  269. 12:13dead. Now, we can use this in our input
  270. 12:16script to just we can say if status
  271. 12:19folder find dead then return. So, none
  272. 12:23of these things in here will run if he's
  273. 12:25dead.
  274. 12:26So we can say if status folder find shot
  275. 12:29dead then
  276. 12:30return or even better we can disconnect
  277. 12:33this update function. So we can say
  278. 12:37local render or local step connection
  279. 12:41equals
  280. 12:42no step connection equals that and we
  281. 12:45can say step connection disconnect like
  282. 12:49so. And step connection equals no like
  283. 12:52so.
  284. 12:54So now if we play the
  285. 12:57game and we start punching, but if we
  286. 13:00die, you see that we can't punch and we
  287. 13:02can't block or do anything like that.
  288. 13:05And if we respawn, we can punch
  289. 13:08again. Like
  290. 13:13so. Another thing I'm going to do is I'm
  291. 13:15going to remove all of these print
  292. 13:17statements here. So we can just comment
  293. 13:18all these out.
  294. 13:28like so.
  295. 13:34And another thing I'm going to do is add
  296. 13:38stunning checks to the combat system.
  297. 13:41So, in the previous video, we didn't
  298. 13:43actually check if the player was stunned
  299. 13:45when they're attacking. So we can just
  300. 13:47add um a comma here and we can say
  301. 13:50stunned like
  302. 13:53so and that should be
  303. 13:56good. Another thing we can do is we can
  304. 13:59check if the player is stunned once
  305. 14:01their hitbox starts trying to
  306. 14:03detect. So we can say if state service
  307. 14:08check state character, stunned then
  308. 14:10return. So if they're stunned when they
  309. 14:14are while the hit box is being made,
  310. 14:16then we'll just return end because we
  311. 14:17don't want anything to happen because so
  312. 14:19because this will cause things like
  313. 14:22players hitting each other at the same
  314. 14:24time and things like that. We only want
  315. 14:25a single player to be able to hit
  316. 14:27another person once. We don't want them
  317. 14:29clashing with each
  318. 14:32other. And we'll check over here. Yep,
  319. 14:35this shouldn't affect anything for the
  320. 14:37game. And that should be good.
  321. 14:44And let's see if there's anything else
  322. 14:48we want to
  323. 14:50do. Ah, another thing we want to do is
  324. 14:52we want to add the block reactions or
  325. 14:55the block stroke because you notice in
  326. 14:57the animation resources that I left in
  327. 15:00the description, there was something
  328. 15:02called block reaction shrug one and
  329. 15:04shrug two.
  330. 15:05So, we're going to use these to actually
  331. 15:07make the dummy have a sort of animation
  332. 15:10when they get hit while they're
  333. 15:12blocking. As you see, right now there's
  334. 15:14no animation. So, in order to do that,
  335. 15:16we can go
  336. 15:19to our hit types and blocked. And we can
  337. 15:23copy the same code right here that we
  338. 15:24had for block
  339. 15:27break, but instead we'll notice that the
  340. 15:30block reactions is um one and two. So we
  341. 15:34can randomize between two different
  342. 15:36animations. So we can let's put this in
  343. 15:38a different
  344. 15:40thread and then we can
  345. 15:43say local random shrug equals
  346. 15:45math.random one comma 2. So it's going
  347. 15:48to randomize between one and
  348. 15:50two. Now we can
  349. 15:52say weapon used dot dot
  350. 15:56doblock.reactions dot tworing random
  351. 16:00stroke and we can play
  352. 16:01it. Otherwise, we can just say let's add
  353. 16:05in the assets folder
  354. 16:07here. We say assets animations
  355. 16:11dot weapon
  356. 16:18used.block.reactions
  357. 16:19shrug one two string one or yeah two
  358. 16:24string random shrug like
  359. 16:27so. And over here we also want to fix
  360. 16:31that we have that shrug and
  361. 16:34one. Now if we play the game you'll
  362. 16:37notice that we have an animation
  363. 16:42added. So if we see what
  364. 16:45happened animations model module load
  365. 16:51animation. Ah okay.
  366. 16:55So in our zombie we also want to load
  367. 17:00the the fist animations. So animation
  368. 17:03modules load animations humanoid
  369. 17:07oops
  370. 17:09humanoid,
  371. 17:10dofist. So this will load the animations
  372. 17:13that we need which contain the shrug and
  373. 17:15things like that because previously we
  374. 17:16only loaded the character animation.
  375. 17:19So let's do the same thing
  376. 17:22for the other dummies.
  377. 17:26Oh, these don't have core. Okay, we'll
  378. 17:28be fine then. All right.
  379. 17:32So, now you notice if we
  380. 17:34play, you'll see that we have the shogun
  381. 17:38emission
  382. 17:41loading.
  383. 17:45So, right. All right. Other thing we
  384. 17:48want to do is we want to make the
  385. 17:51character be frozen and have a little
  386. 17:54end lag on the left tip because right
  387. 17:57now you'll see that
  388. 17:59the player can freely move in less than
  389. 18:02one. We don't really want that. We want
  390. 18:04that. We want them to have a little bit
  391. 18:05of end lag and for them to be frozen in
  392. 18:08place on their less than one if we so
  393. 18:10want to. So in the hit types, we can go
  394. 18:13to
  395. 18:14default and we can add on to the last
  396. 18:17hit thing right here. We can say
  397. 18:20freezing in place or this will be just
  398. 18:22called end
  399. 18:23lag. So we can add a status to this
  400. 18:29called let's say no no move. And we want
  401. 18:33this to be about like
  402. 18:35one one and two10 of a second. And we
  403. 18:38also add a state here called stun or
  404. 18:42oops, not check state, add state. And we
  405. 18:45want to add a state called no attack
  406. 18:48because we don't want them to be able to
  407. 18:50attack within this time frame, but we
  408. 18:52want them to be able to block and things
  409. 18:54like that. So we'll add something called
  410. 18:56no
  411. 18:56punch. However, because we added that
  412. 18:59state, we also need to add this up here.
  413. 19:02So we'll say no punch. Then do
  414. 19:06that. Now we can go to our input and we
  415. 19:10can add onto our little state handler
  416. 19:12status updater here and we can say if
  417. 19:15status folder find first child no
  418. 19:19punch or we can say no move then final
  419. 19:23jump power equals zero final walk speed
  420. 19:25equals zero as
  421. 19:26well and I also forgot to add the stun
  422. 19:29status in here so while they're stun of
  423. 19:32course we don't want them to move or be
  424. 19:33able to jump so add it like this Another
  425. 19:37thing I want to note is if you recall,
  426. 19:39Robux reads their code from top to
  427. 19:42bottom. So, knowing so, we want to make
  428. 19:45sure to prioritize which states come
  429. 19:47first. What I mean by that is if we were
  430. 19:50to add no move or if we were to add
  431. 19:53stunned up here because Roblox reads it
  432. 19:56from the top to bottom, the stun status
  433. 19:58will be overrided by attacking
  434. 20:01status. If that makes if that makes any
  435. 20:03sense. So because of that, we'll want to
  436. 20:06add stunned as the last sort of state
  437. 20:10that we want to be updated for the
  438. 20:12character.
  439. 20:14Now, if we play the game,
  440. 20:19you'll see that on the last hit, the
  441. 20:22player doesn't stop moving because they
  442. 20:25act didn't hit anything. So that'll
  443. 20:26that'll be fine.
  444. 20:28But they hit something. You'll see that
  445. 20:31they can't move for one or two times of
  446. 20:33a second. And then they can move
  447. 20:38again like
  448. 20:44so. And so that's going to pretty much
  449. 20:47wrap up this sort of intermission video
  450. 20:495.5.
  451. 20:51So mainly today what we did was
  452. 20:55we fixed it to where you if when you die
  453. 20:59you won't be able to punch or block or
  454. 21:00anything like that by adding a folder to
  455. 21:03status called dead whenever the
  456. 21:04character dies on the server. And also
  457. 21:07we added blockstroke animations using
  458. 21:09the code that we already had for block
  459. 21:11brick but rather we just added a muff
  460. 21:13random to randomize between one and two
  461. 21:16blockstrokes. And we also added a
  462. 21:19collision handler, which just makes it
  463. 21:20to where players can't collide with
  464. 21:23dummies, which can prevent things like
  465. 21:25flinging and unnecessary issues that we
  466. 21:28might face in the
  467. 21:29future. And that pretty much wraps up
  468. 21:32this video. The next video that will be
  469. 21:35released today is going to focus on
  470. 21:37sprinting and dashing, mainly movement.
  471. 21:40So yeah.

About this transcript

This page contains the full transcript of [Part5.5] Roblox Combat System for Beginners | Collision Groups & Minor Fixes by Senko, generated from the public captions YouTube serves with the video. The transcript has 2,914 words across 471 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.