YouTube2Text

[Part4] Roblox Combat System for Beginners | Hit Reaction Types — Transcript

by Senko · 3,267 words · 526 segments · language en · Watch on YouTube

Full transcript

  1. 0:00All right. So, I'm going to be showing
  2. 0:01you how to make uh the hit types. So,
  3. 0:05for stunning,
  4. 0:06for blocked, block break, and things
  5. 0:10like that. But the first thing I wanted
  6. 0:12to do is address an issue with
  7. 0:16the input began, the is typing thing for
  8. 0:18the user input.
  9. 0:21So, if we play the game now, you'll see
  10. 0:24that okay, blocking works, but if you
  11. 0:26press shift, it just unblocks like so.
  12. 0:29So a way to fix that
  13. 0:31is it's because it's saying that
  14. 0:35uh left shift and right shift count as a
  15. 0:38sort of game processed event. So if you
  16. 0:40want to get um bypass that we can say if
  17. 0:43processed and
  18. 0:46um change this to
  19. 0:49inputs and I'm going to say if processed
  20. 0:53and input.key
  21. 0:56code is not equal to my key code left
  22. 0:59shift and input.key key code is not
  23. 1:04equal to you know my key code right
  24. 1:06shift
  25. 1:08then we can say is typing was true
  26. 1:13so now if we play the game we'll see
  27. 1:15that okay now if you press shift or
  28. 1:17anything like that it won't unblock if
  29. 1:19you start typing then it will so yeah
  30. 1:22that's
  31. 1:23that now let's go on to the um hit type
  32. 1:28sort of um deal for this
  33. 1:30video So for hit types, it's going to be
  34. 1:34something
  35. 1:35like for um we'll make a folder called
  36. 1:38hit
  37. 1:40types. And then we can make module
  38. 1:42scripts depending on what the hit type
  39. 1:44is. So let's say like okay, you just hit
  40. 1:46them normally. You call that default.
  41. 1:50And we can duplicate this. We can call
  42. 1:51this blocked or block break like so.
  43. 1:56Let's do um focus on default for now.
  44. 1:59Let's call this default hit type just
  45. 2:01for a comment
  46. 2:03and local hit type and then return hit
  47. 2:06type.
  48. 2:10Actually instead of doing this we can
  49. 2:11just say return function and then add
  50. 2:14our variables in here.
  51. 2:16So if we go to
  52. 2:19our fist
  53. 2:21system we can actually start requiring
  54. 2:24these headups.
  55. 2:26So remember in the previous video where
  56. 2:27I was like you if you write
  57. 2:30an if you run code outside of here it'll
  58. 2:34automatically run once the fist is or
  59. 2:36once the module is required. So we can
  60. 2:39say something like requiring head
  61. 2:42types and now we can say for underscore
  62. 2:45module and script.parent parent a parent
  63. 2:48of head types
  64. 2:49do I'll get children
  65. 2:52oops if module is a module script
  66. 2:56then let's say hit types like
  67. 2:59so weapon
  68. 3:03type hitit types module name equals
  69. 3:06require
  70. 3:08module now if we go down here instead of
  71. 3:11just making it take damage like so we
  72. 3:13can
  73. 3:14say get the status folder
  74. 3:17Or we can say local state service which
  75. 3:19you already mentioned up here. So local
  76. 3:21is blocking equal state service check
  77. 3:24state your target hit comma
  78. 3:28blocking like
  79. 3:30so. Now we haven't added a blocking hit
  80. 3:33type in here yet. This is going to be in
  81. 3:35the um future
  82. 3:37minutes um once we add in the default
  83. 3:40type. So we can say if is blocking then
  84. 3:44blocking or like do blocked hit site or
  85. 3:47something like
  86. 3:48that. But otherwise we'll just say
  87. 3:50default hit
  88. 3:52site. Now for this combat system in
  89. 3:55particular, I'm not going to worry about
  90. 3:57sort of thing like a block or posture
  91. 3:59bar. We're just going to make it to
  92. 4:00where if you're on the last M1 or last
  93. 4:02swing, it'll block break.
  94. 4:05So we can say if swing number do value
  95. 4:08is greater than or equal to
  96. 4:10five then last hit which is going to be
  97. 4:14a block
  98. 4:15break. However, we don't need to do this
  99. 4:18up here. We only need to do this if
  100. 4:19they're blocking it. So before we even
  101. 4:22add in the block and block break hit
  102. 4:24types, we can say if swing number value
  103. 4:28is greater than or equal to five or we
  104. 4:31can't do that because we already reset
  105. 4:32it. So we will do true swing
  106. 4:35number. If true swing number is greater
  107. 4:38than equal to five then block break.
  108. 4:42Otherwise we just do the blocked hit
  109. 4:45type like so. But here we'll just
  110. 4:49say our weapon type dot hit types
  111. 4:54default and then we will do the open
  112. 4:56parenthesis because this is going to run
  113. 4:58the function because we return the
  114. 5:00function. But now we need to add in
  115. 5:02variables or parameters so we know who
  116. 5:06exactly we're hitting and things like
  117. 5:07that. So here we can just say okay we
  118. 5:12want the character we want
  119. 5:15the target hit things like that and we
  120. 5:19also want the weapon
  121. 5:22used. So let's see if we have that up
  122. 5:25here
  123. 5:26anywhere. Here we go. Yep. To name. So
  124. 5:29we can say to name like
  125. 5:32so. Now we can go over here we can say
  126. 5:35um attacker we can say target hit,
  127. 5:39weapon use like
  128. 5:41so. And we can also if we want it to
  129. 5:44autocomplete. So we can add annotations
  130. 5:46in here. So if we go to fist we can say
  131. 5:49okay we know the character is going to
  132. 5:51be a
  133. 5:52model. We know the target hit is also
  134. 5:55going to be a model. And we know the
  135. 5:57weapon used is going to be a string.
  136. 5:58Like
  137. 5:59so. Now we can make it do damage. So
  138. 6:03we'll say we'll require
  139. 6:08the weapon data. So we say weapon data
  140. 6:11module. Let's get our services
  141. 6:16first. Local
  142. 6:18modules. I'm going say weapon data
  143. 6:20module equals require modules weapon
  144. 6:23data.
  145. 6:25Now we can say local found weapon data
  146. 6:28weapon data module get weapon data
  147. 6:30weapon used. It found weapon data. Done.
  148. 6:34Now we can check for the target
  149. 6:39humanoid. Target hit. Find shot
  150. 6:42humanoid. If not target humanoid then
  151. 6:45return
  152. 6:46end. And now we can make it do damage.
  153. 6:49So we can say target humanoid take
  154. 6:52damage. You see it doesn't autocomplete.
  155. 6:54So we can say annotate as a humanoid.
  156. 6:57Now it auto completes it for you. Take
  157. 7:00damage and then we can say go to our
  158. 7:04thing right here dot damage if we
  159. 7:06recall. So we can say found weapon data
  160. 7:09damage like
  161. 7:11so. And then just for like um we can add
  162. 7:14a print statement and we can say default
  163. 7:18hit type reached and we can say comma
  164. 7:21attacker target hit weapon use like
  165. 7:24so just so we know that the um the
  166. 7:28module is actually
  167. 7:30called. So now let's review the
  168. 7:34code and yep it should work.
  169. 7:41So if we play the game,
  170. 7:44we'll see. Okay, our punching works, our
  171. 7:46blocking works. If you punch him, you
  172. 7:48can see that okay, hit type reached and
  173. 7:51hit dummy
  174. 7:52fist. So we know that works. Now we can
  175. 7:56start working on things like our blocked
  176. 7:58hit type. So if we duplicate this, we
  177. 8:01can call this
  178. 8:02blocked. And then after that we can
  179. 8:05refer back to our fist script and we can
  180. 8:08say weapon type dot or weapon yeah
  181. 8:11weapon type hit types block and then we
  182. 8:14can call it like
  183. 8:16so to name. Now I want to note like how
  184. 8:21exactly useful this is because the
  185. 8:24reason we pass in the weapon use string
  186. 8:26right is because let's say we want um a
  187. 8:29unique sort of effect or um something
  188. 8:34like that. We can say if weapon used
  189. 8:36equals equals let's say sacred uh sacred
  190. 8:40katana or something. We can add like a
  191. 8:43really cool effect if we want to and
  192. 8:45things like that. Or if we want it to be
  193. 8:47default, we can say oh else we'll just
  194. 8:50do a normal normal hit
  195. 8:53effect. But we're going to do um an
  196. 8:58effects handler in the next video. But
  197. 9:00for now, we're just going to work on
  198. 9:02this. So we can go to
  199. 9:04blocked. We can say blocked hit type
  200. 9:08reached. And here we don't want to take
  201. 9:10any damage. Or if we do, we can go to
  202. 9:13our weapon data module. We can say chip
  203. 9:16damage. Essentially chip damage. Um,
  204. 9:19it's just block damage or we can change
  205. 9:22this to block damage. There we go. We
  206. 9:24can say, okay, we want them to take like
  207. 9:26two damage if they're blocking or
  208. 9:27something like
  209. 9:28that. Now, we can just go back to
  210. 9:31here, go to block, and we can say target
  211. 9:35humanoid take damage found weapon
  212. 9:36data.block damage. Like so.
  213. 9:40And I forgot to add a stun in here. So
  214. 9:44we can say local state service equals
  215. 9:48require script. parent state
  216. 9:52service. Now we can say
  217. 9:56oops. Let's organize this white space.
  218. 9:58All right. Add state target
  219. 10:02hit, stunned. And we can make them
  220. 10:04stunned for like maybe 4
  221. 10:06seconds like so.
  222. 10:10And then we can go to our state service
  223. 10:15because this might this line might not
  224. 10:17work because the target hit isn't an
  225. 10:20actual player and it doesn't have the um
  226. 10:23the state service folder in it or the
  227. 10:24status folder in it. So if we want to
  228. 10:28fix that, we go to state
  229. 10:30service add state and you'll see it will
  230. 10:33definitely not work because we set a not
  231. 10:35status folder then. But if it doesn't
  232. 10:37find it, we can just say something like
  233. 10:40uh status folder is equal to instance
  234. 10:42new folder status folder.name equals
  235. 10:45status and status folder.parent equals
  236. 10:48the character or in this case the
  237. 10:50character would be target hit. So this
  238. 10:52is going to work now. So if we just get
  239. 10:55out of that and we go back to blocked or
  240. 10:58default the stunned should work. So
  241. 11:01let's go over here and look at it.
  242. 11:06We play the game. We look in.
  243. 11:10Let's look at hit dummy.
  244. 11:13And you'll see that he has a status now.
  245. 11:15Oops. Let's open it. Yep. You say he's
  246. 11:18stunned.
  247. 11:20And after that, let's go to like
  248. 11:22animation dummy. You'll see that
  249. 11:23automatically makes a new status folder
  250. 11:25too. And stun gets
  251. 11:29added. Now, let's go back to the block.
  252. 11:32Let's make a new dummy called block
  253. 11:34dummy. So we can duplicate the hit dummy
  254. 11:36we have and just call this block
  255. 11:40dummy like so. And let's just add a
  256. 11:43script in here so it can play the
  257. 11:45animation. So we just uh let's just
  258. 11:47duplicate the auto
  259. 11:50animation. We call this block
  260. 11:52anim. Now we can say local block
  261. 11:56animation equals or no let's say local
  262. 11:59humanoid script. Uh
  263. 12:02humanoid block animation humanoid oops
  264. 12:05do
  265. 12:07animator humanoid load animation script
  266. 12:10of block
  267. 12:11animation
  268. 12:14play. So yeah that should
  269. 12:18work. So if we play the
  270. 12:20game we'll see that the yep the block
  271. 12:23animation plays but we didn't account
  272. 12:26for the fact that we need to actually
  273. 12:27add the block status into the player.
  274. 12:31So
  275. 12:33let's go over here and we can add a
  276. 12:35status folder in here called block
  277. 12:36called
  278. 12:43status equals script. parent or another
  279. 12:47way we could do this is just add a
  280. 12:48folder called status in here but I'm
  281. 12:50just going to do it script wise for now
  282. 12:52because it doesn't really matter in the
  283. 12:54end and for that we can just add a block
  284. 12:57status or local
  285. 12:59blocking instance new folder blocking
  286. 13:03name equals
  287. 13:04blocking blocking parent status folder
  288. 13:06like
  289. 13:08so now if we play the game
  290. 13:15And then we open the blocked dummy. See,
  291. 13:18he has a blocking thing in here. So, we
  292. 13:21hit him. We'll see that. Okay, we have
  293. 13:23blocked hitype breached.
  294. 13:27Yep. Like
  295. 13:29so. But now we actually have to work on
  296. 13:32the block
  297. 13:34break because that's how we scripted it
  298. 13:37for it to block break on the last swing.
  299. 13:40So we can duplicate the blocked module
  300. 13:44and we can call this block break and we
  301. 13:46can duplicate this code and say block
  302. 13:50break like
  303. 13:52so. Now we don't want the block break to
  304. 13:55actually make them take damage. We just
  305. 13:56want them to be stunned for a long time.
  306. 13:59So we can say block break hits breached
  307. 14:02and we can
  308. 14:03say get the state service in here.
  309. 14:08Now we can say local or state service
  310. 14:11add state a target hit comma stunned and
  311. 14:16we want it to be stunned for around 1.5
  312. 14:18seconds. We can also add another state
  313. 14:20called block
  314. 14:22broken for
  315. 14:241.5. There we go. And notice how these
  316. 14:27two durations are the
  317. 14:29same. And we can also play the block
  318. 14:32break animation.
  319. 14:34So
  320. 14:37one way we can do this is we can use
  321. 14:39load
  322. 14:40animation on the animator.
  323. 14:43Oops. Animator
  324. 14:46or we can make a animations module in
  325. 14:50here. So we can account for two of these
  326. 14:53things. So we can say um as you'll see
  327. 14:57that in our character we have the core
  328. 15:00and then
  329. 15:01animations. So we'd also need to
  330. 15:03duplicate the core and add that into
  331. 15:04there like so. Oh, we're going to remove
  332. 15:07the input because we don't want the
  333. 15:09dummy to be accessing client script. So
  334. 15:12see
  335. 15:13this and after that we can go over here
  336. 15:18we can say if target hit find for child
  337. 15:21core then local animations
  338. 15:27module equals
  339. 15:29require target hit.core record
  340. 15:32animations and we can say
  341. 15:34animations.loaded
  342. 15:36animations. Let's remove the block.
  343. 15:38Let's move the block break to just the
  344. 15:40um normal animations.
  345. 15:42So we can just add a new folder in here
  346. 15:44called
  347. 15:46character like so
  348. 15:49and we can just go over here block
  349. 15:51break. So go to animations and we can
  350. 15:54say
  351. 15:56character.block break and we can say
  352. 15:59play. Otherwise, we'll just load the
  353. 16:01animation normally. So, we can say local
  354. 16:04animator target humanoid uh
  355. 16:08animator or we can say find for child
  356. 16:11animator cuz what if it's not
  357. 16:13there? So, if
  358. 16:15animator then we can say local block
  359. 16:20break equals animator load animation.
  360. 16:24Let's add an autocomplete to this. So,
  361. 16:26annotate this like so.
  362. 16:29So now we can call that
  363. 16:31animation and then we can
  364. 16:33say let's add an assets variable in
  365. 16:38here. We can say
  366. 16:40assets dot character.block break oops
  367. 16:44animations character blockbreak and we
  368. 16:47can say block break animation play like
  369. 16:49so. So this is going to account for the
  370. 16:51fact that okay there's a core and an
  371. 16:53animations module then we play the
  372. 16:55normal animation. We don't need to load
  373. 16:56it. But if there's not, we'll just um
  374. 16:59load it and we'll play
  375. 17:02it. So in the script over here, we can
  376. 17:05just require
  377. 17:06the animations
  378. 17:09module. Require
  379. 17:12script.parent.core animations. We say
  380. 17:15animation modules load anim. And we can
  381. 17:18say gamer to assets animations
  382. 17:22character. Like so.
  383. 17:24Now, if we just get out of that script
  384. 17:27and we go over here,
  385. 17:30we'll also want the dummy to reblock
  386. 17:32after they're done block broken. So, we
  387. 17:35can replicate
  388. 17:36that. So, we can
  389. 17:38say we can say while true
  390. 17:43do or we can say yeah while true
  391. 17:49do test. Okay, cuz remember if you don't
  392. 17:52add a test weight, it's just going to
  393. 17:54spam the same thing multiple times and
  394. 17:56it's going to cause the script to break
  395. 17:58and output something like script exhaust
  396. 18:00time. So add a wait and we'll
  397. 18:04say if status folder find first child
  398. 18:07block broken or status folder find for
  399. 18:11child stunned then we can say
  400. 18:14uh blocking
  401. 18:18destroy otherwise we'll just reblock him
  402. 18:20and we also want to stop the animation
  403. 18:24so block animation stop. Otherwise,
  404. 18:28we'll just create a new blocking
  405. 18:30instance. So, let's make this function
  406. 18:32create blocking instance like
  407. 18:36so. And then we can just call that
  408. 18:38function. Remember the do not repeat
  409. 18:40yourself. So, we just call the function
  410. 18:42here. And we'll also
  411. 18:45[Music]
  412. 18:48say_, V inside folder, which should do
  413. 18:52v.name equals then v
  414. 18:55destroy or v.name name equals blocking
  415. 18:57my false.
  416. 18:59Otherwise, we'll just say create
  417. 19:01blocking instance. And we want to play
  418. 19:02the animation.
  419. 19:05And then over here, if since we don't
  420. 19:07want it to spam play the animation, we
  421. 19:09can say if block
  422. 19:10animation is playing, then we want to
  423. 19:14stop. Otherwise, we can say
  424. 19:18if block animation if not block
  425. 19:20animation is
  426. 19:23playing, then block animation play.
  427. 19:27And we don't want to spam create a ton
  428. 19:28of blocking instances. So we can say if
  429. 19:31not satisfer find for shot blocking.
  430. 19:34Then we do
  431. 19:35this. And there we go. That's this is
  432. 19:38going to allow for the dummy to reblock
  433. 19:40after it's been
  434. 19:41guardbroken. So if we play the game,
  435. 19:44we'll see an error. Let's see.
  436. 19:48Attempt to index nil with get
  437. 19:50descendants. Oh, forgot to fill in the
  438. 19:52animator variable. Okay. Or parameter.
  439. 19:55So, if we go over here, we'll see that
  440. 19:59right here. We can go to script.parent.h
  441. 20:03humanoid.an animator like so. And let's
  442. 20:07just go over here.
  443. 20:09We'll do all this. Move this up
  444. 20:12here. Remove all of this. So, we can
  445. 20:15instead of doing script apparent
  446. 20:16humanoid, we can just say humanoid like
  447. 20:19so.
  448. 20:21And let's go over here.
  449. 20:27game and you'll see that it works. So,
  450. 20:29he's blocking and we can see that. Okay.
  451. 20:33And then he's guard
  452. 20:35broken. And then if we He's doing a lot
  453. 20:39of damage. Hold
  454. 20:41on. Let's go to our blocked site. Block
  455. 20:46damage.
  456. 20:54Let's see.
  457. 20:59Oh,
  458. 21:01okay. So, yeah, interesting. Well, let's
  459. 21:05just remove this part of the script. And
  460. 21:07there we go. It should be fixed.
  461. 21:09Okay. Now, if we go back to the block
  462. 21:12and let's just remove all these prints
  463. 21:14over here. Now, it should work. So,
  464. 21:17let's just go over here to fist. We'll
  465. 21:19change this to two again.
  466. 21:21And then if we play the game, it should
  467. 21:24be fine now.
  468. 21:26Yep, there we go.
  469. 21:28And you see that he block breaks for a
  470. 21:30little bit and then he goes
  471. 21:33back like
  472. 21:35so. So let's increase the block break
  473. 21:38time or no, let's make him reblock after
  474. 21:42a little bit. So we can
  475. 21:44say if not satisfied or find shot
  476. 21:46blocking then we can say
  477. 21:48test weight one and make him reblock.
  478. 21:59There we go. Now we wait one and now we
  479. 22:02rebu like
  480. 22:04so. And in that time frame, we can do,
  481. 22:07you see how it's normal damage, but if
  482. 22:09you
  483. 22:10reblocks, you see that? Yep. Works.
  484. 22:14And if we look at his status folder, you
  485. 22:17see it's only a single
  486. 22:19blocking, which works because test.wait
  487. 22:22will yield this whole loop until this
  488. 22:25part is
  489. 22:26called. And yep, that's that.
  490. 22:34So, that's going to be pretty much it
  491. 22:36for this episode. Mainly, I just wanted
  492. 22:38to focus on adding in new hit types and
  493. 22:42showing y'all how
  494. 22:43to incorporate them in the script. So,
  495. 22:46you see that we made it okay, we block
  496. 22:48on the last M1. And otherwise, we do a
  497. 22:50blocked effect. And then if none of
  498. 22:54those apply, then we just do the normal
  499. 22:55hit
  500. 22:56type. And it's very easy to configure
  501. 22:59them because if we want to have a unique
  502. 23:01functionality, we can say weapon use
  503. 23:03blah blah blah like I mentioned earlier.
  504. 23:07And you see that block damage, we have
  505. 23:09just the default damage over here. And
  506. 23:12then here I made I showed you how
  507. 23:16to if the if there's no animation module
  508. 23:20in here, then we just load the
  509. 23:22animation, we play it. Otherwise, we
  510. 23:25just get the animations module and then
  511. 23:27we play
  512. 23:28it. So,
  513. 23:31yeah. So, that's going to wrap up this
  514. 23:33video. The next video is going to be
  515. 23:35released later today as well, and it's
  516. 23:38going to focus on adding visual effects
  517. 23:40to our combat system, cuz right now, the
  518. 23:43combat system honestly looks extremely
  519. 23:45bland, and we don't want it looking like
  520. 23:49this when we release it.
  521. 23:52So, we will add visual effects like a
  522. 23:56little blocked effect and a block break.
  523. 23:57Sort of like a dizzy I'm spinning around
  524. 24:00effect, a hit effect and things like
  525. 24:03that. So, yeah. Hope you enjoyed the
  526. 24:05video. See you.

About this transcript

This page contains the full transcript of [Part4] Roblox Combat System for Beginners | Hit Reaction Types by Senko, generated from the public captions YouTube serves with the video. The transcript has 3,267 words across 526 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.