YouTube2Text

[Part7] Easy Roblox Combat System for Beginners | Adding in Weapons & Fixing Bugs — Transcript

by Senko · 5,886 words · 923 segments · language en · Watch on YouTube

Full transcript

  1. 0:00All right. So, this is going to be the
  2. 0:02sort of introduction to episode 7. So,
  3. 0:05today I'm going to show you how to add
  4. 0:06in different weapons as well as
  5. 0:10uh cloning these weapons into your
  6. 0:11inventory which you can which should be
  7. 0:13the final product by the end of the
  8. 0:14video where we have four different
  9. 0:17blocks which this one clears all your
  10. 0:19weapons and these ones gives you the
  11. 0:20dagger, katana, and the fist. And as you
  12. 0:23can see, whenever it gets added to your
  13. 0:27uh player uh gives you the weapon model
  14. 0:29too. And if you clear them, they get
  15. 0:30destroyed. So let's give me fist and the
  16. 0:33katana. You see the katana gets added
  17. 0:35and the dagger also gets added. And we
  18. 0:37also worked on transitioning between
  19. 0:39animations. So you see if we're running
  20. 0:41and we equipped a dagger, then it
  21. 0:43changes as well as the katana, it
  22. 0:45changes as well. And if we unequipped
  23. 0:47everything, you'll see that the
  24. 0:48animation changes to the
  25. 0:50default. And we also worked on adding in
  26. 0:54different uh slash effects and sounds
  27. 0:56based on the weapon you have. So for
  28. 0:58example, your
  29. 0:59fist is just your normal your normal hit
  30. 1:02sound. But if you switch to dagger, then
  31. 1:04you have a little dagger
  32. 1:06sound.
  33. 1:08So similarly, your or I said dagger
  34. 1:12earlier and then sword. And similarly,
  35. 1:14your dagger will have a dagger sound.
  36. 1:20So, this there's going to be a lot of
  37. 1:21mini edits in this video, as well as me
  38. 1:24addressing some bugs that uh I saw in
  39. 1:28the comment sections from uh previous
  40. 1:30videos. So, yeah, hope you enjoy the
  41. 1:32video and please leave a like, um
  42. 1:35subscribe cuz I do put a lot of effort
  43. 1:38into these videos and I would really
  44. 1:39appreciate it. And see youall in the
  45. 1:41video. All right, welcome to episode 7.
  46. 1:46So, this is probably going to be the
  47. 1:47last episode before the end of the
  48. 1:50series, which is going to be episode
  49. 1:52eight, marking the end of this. But in
  50. 1:55this episode, we're going to be focused
  51. 1:56on adding in two new weapons, or adding
  52. 1:59multiple weapons if you want to. But in
  53. 2:02this video, the two weapons we're going
  54. 2:03to be adding are the sword and the
  55. 2:08dagger. And all the animations that I
  56. 2:10have for y'all will be in the
  57. 2:11description. So, if there's any issues
  58. 2:14with the animations not loading or
  59. 2:16anything like that, just comment down
  60. 2:18and ask for help. And yeah, let's get
  61. 2:22started. So, the first thing we want to
  62. 2:24do is we want to duplicate the fist
  63. 2:27tool.
  64. 2:29So you'll notice that in all of So first
  65. 2:33off, if we look up fist, you'll see that
  66. 2:35the two main scripts that are handling
  67. 2:37the fist are the weapon data fist and
  68. 2:41the weapons.fist in our systems folder,
  69. 2:45as well as the fist
  70. 2:47tool. So we're going to want to
  71. 2:50duplicate
  72. 2:51the tool first. And let's call this
  73. 2:54sword, like so.
  74. 2:57and we will open tool loader and you'll
  75. 2:59see that we still have the assets
  76. 3:02animation pist. So let me show you how I
  77. 3:05organize the
  78. 3:06animations which it should look
  79. 3:08something like this. So we have our
  80. 3:11idle and our run animations that contain
  81. 3:13sword and dagger and sword and dagger
  82. 3:16corresponding as well as a new
  83. 3:18animations folder which just organiz
  84. 3:21which are just organized like this.
  85. 3:26So, we're going to want to load the
  86. 3:28sword animations like so. Let's exit out
  87. 3:31of that. Now that we duplicated that, we
  88. 3:34can also duplicate the weapons
  89. 3:37uh fist module and call this sword like
  90. 3:41so. And we'll check for anything in here
  91. 3:44called fist.
  92. 3:46Like so. So, you see that if you see
  93. 3:49fist, we'll just change this to sword.
  94. 3:51Oops. And then we will change this to
  95. 3:53sword.
  96. 3:55So the reason this works is because the
  97. 3:57anim the corresponding animations are
  98. 4:00also called sword. And then so you see
  99. 4:02score swords swings 01 like so because
  100. 4:06that's how we created or loaded the
  101. 4:08animations in our animations module like
  102. 4:11so because we split the
  103. 4:13string. Now going back let's go ahead
  104. 4:17and change all these values. This is
  105. 4:20just the name of the module. Another
  106. 4:23thing I forgot to mention is the sounds.
  107. 4:25So we also have the sim a similar thing.
  108. 4:28So dagger and sword like
  109. 4:31so. And we also want to add this to the
  110. 4:37shared weapon data. So we duplicate
  111. 4:38this. We can change this to
  112. 4:41sword like so. And you see block damage
  113. 4:45damage. We can keep that the same if we
  114. 4:47want. And then now we can play the
  115. 4:52game. You see that if we equipped,
  116. 4:55you'll see the animation starts playing
  117. 4:56and you see the
  118. 4:58run like
  119. 5:05so. However, you'll notice something
  120. 5:07really funny. There is absolutely
  121. 5:11um no sword model. So yeah, we're going
  122. 5:15to need to fix that. Another thing I'll
  123. 5:16fix is you'll see how the animation
  124. 5:18abruptly stops. Uh in order to fix that,
  125. 5:20we can just change out the fade time
  126. 5:23like so. We can change this to
  127. 5:26uh let's say three and we can change
  128. 5:28this
  129. 5:29three as well as going down here to our
  130. 5:32animations and we can change this
  131. 5:35to three as well. So we can change this
  132. 5:37to three
  133. 5:39and
  134. 5:41three. Now we play the game. You'll see
  135. 5:43that the animations have a slow fade in
  136. 5:45and they don't just abruptly stop. There
  137. 5:48we go.
  138. 5:53You'll see that if
  139. 5:54we
  140. 6:01run. All right. Now, we can add in
  141. 6:04[Music]
  142. 6:07the the sword model. So, in
  143. 6:13the resource tab for yall, I have both
  144. 6:15of the weapon models in
  145. 6:17here. So, we can duplicate this folder
  146. 6:21and then we can just parent this to the
  147. 6:25assets weapons and we just call it
  148. 6:28weapons
  149. 6:28folder. And then in our sword, we can
  150. 6:31now
  151. 6:34uh create the or we can clone these two
  152. 6:39sword models. So this is when the sword
  153. 6:41is going to be on your back or
  154. 6:43unequipped and this is going to be when
  155. 6:45your sword is equipped. So Roblox gives
  156. 6:47you two functions. It gives you tool
  157. 6:49equipped and it gives you tool
  158. 6:51unequipped like
  159. 6:54so. So first off we want to do is we
  160. 6:56want to actually create or clone these
  161. 6:59models beforehand. So we can say local
  162. 7:02back model and we can say local equiped
  163. 7:04model like
  164. 7:06so. And then we can go over here and we
  165. 7:09can reference
  166. 7:11the
  167. 7:13weapons weapon
  168. 7:17models weapons and we can say assets do
  169. 7:21sword
  170. 7:23dot we can say weapon models sword dots
  171. 7:27swordback
  172. 7:28clone and then we want to weld this to
  173. 7:31the
  174. 7:33torso. So say back model.weld world
  175. 7:37dot part one is equal to our character
  176. 7:42humanoid part like so. And we just want
  177. 7:46to parent this to the
  178. 7:49player. And the same thing for this. We
  179. 7:51want
  180. 7:53to w this to the right arm because
  181. 7:57that's the arm that's going to be
  182. 7:58equipped when the player starts
  183. 8:00attacking. Equip model.load Well do
  184. 8:04parts one is equal to character humanoid
  185. 8:08or character right
  186. 8:09arm. We can say equip a model. parent is
  187. 8:13equal to character. And that should be
  188. 8:16good. So if we play the
  189. 8:19game, you'll see that our sword model is
  190. 8:24on the back. But you'll see that we need
  191. 8:26to make this equip model transparent.
  192. 8:31So in order to do that we can just
  193. 8:33say make a function up here called
  194. 8:36toggle equipped and we can say
  195. 8:39boolean. So we can say or we call this
  196. 8:43is
  197. 8:44equipped. So is
  198. 8:46equipped then we want to make the back
  199. 8:50model
  200. 8:52transparent and equipped model
  201. 8:56um visible. Otherwise, we want to make
  202. 8:59the back model visible and equipped
  203. 9:02model
  204. 9:04transparent. So, we go over here and we
  205. 9:07can
  206. 9:09say for
  207. 9:11unerscore, V and back model get
  208. 9:14descendants
  209. 9:15too. And we can check if it's a V is a
  210. 9:20base part or
  211. 9:21[Music]
  212. 9:23V is a mesh part.
  213. 9:28or V is a parts or V is
  214. 9:31a unit operation then we can say
  215. 9:34V.transparency is equal to
  216. 9:37one. As for the equiped model we can
  217. 9:40just set all of these to zero like
  218. 9:43so. And similarly to this we can just
  219. 9:46say zero and we can say
  220. 9:50one. So we can run this. We can say
  221. 9:52toggle equipped false because it's not
  222. 9:55equipped. I'm going to say top equip to
  223. 9:57true, toggle to false. Like
  224. 10:00so. Now, if we play the
  225. 10:04game, you'll see that our weapon model
  226. 10:06is not visible. If we equipped it, you
  227. 10:09see that it
  228. 10:11is. And of course, the animations work
  229. 10:16now.
  230. 10:18So, if we change it, you'll see that the
  231. 10:21animations are good.
  232. 10:28So
  233. 10:36all right,
  234. 10:39next up we want to add in the dagger.
  235. 10:44So we'll similarly we'll do the same
  236. 10:46thing. We will duplicate
  237. 10:50this and then we will also check for
  238. 10:54anything called sword. Just change this
  239. 10:56to dagger
  240. 11:05and we will
  241. 11:07duplicate
  242. 11:09our weapon data. Change this to dagger
  243. 11:12as well.
  244. 11:14We will create
  245. 11:15a tool called dagger.
  246. 11:20And here we just want to do the similar
  247. 11:22thing, but instead we'll say
  248. 11:25dagger. And we'll say dagger
  249. 11:29deck.
  250. 11:31Dagger dagger
  251. 11:33equipped. And then that should be good
  252. 11:35for that. And we also need to change the
  253. 11:36animation so it loads all of them.
  254. 11:41So, that should be pretty much it for
  255. 11:43the
  256. 11:46dagger. Oh, let's see what the problem
  257. 11:48is with this. Ah, okay. It's because the
  258. 11:52models are all different. So, we need to
  259. 11:53account for that because you'll see that
  260. 11:55dagger we have a primary part, but here
  261. 11:58we only have a weld. So, we need to
  262. 12:00actually go in the primary part and then
  263. 12:01weld this. So in here we'll just say
  264. 12:04dagger or back model primary part do
  265. 12:08handle
  266. 12:10weld part one equals our human part. And
  267. 12:14in here we'll just weld this to the
  268. 12:16right arm like
  269. 12:17so. So we'll say primary part handle or
  270. 12:22no weld part one and then we'll
  271. 12:26say weld.part one like so.
  272. 12:32Play again. Let's
  273. 12:36see. Primary part.
  274. 12:44Let's see. Oh, okay. We didn't set the
  275. 12:47primary part in here. That's why. So, we
  276. 12:49want to set this to that. And that
  277. 12:50should be
  278. 12:52good. Now, if we play the game, you will
  279. 12:55see that we have both of our animations
  280. 12:58or our weapon models in. We see that it
  281. 13:02looks kind of weird when we're running
  282. 13:03because it's what it's the humanoid root
  283. 13:05part. Typically in Roblox or just always
  284. 13:09in Roblox, the humanoid root part is
  285. 13:11different from the torso cuz you see
  286. 13:14this is the torso, but the humanoid root
  287. 13:16part sort of is in place the whole time.
  288. 13:19You see that it doesn't move along the
  289. 13:21torso. So, we just want to weld both of
  290. 13:24these to the torso. So, we'll say
  291. 13:26character.rso torso and then we will
  292. 13:28also say sword or dagger and we'll
  293. 13:32change this to
  294. 13:33torso like
  295. 13:36so. Now if we play the
  296. 13:38game, you'll see that the weapon
  297. 13:41actually follows the character. Now if
  298. 13:43you equipped it, you'll see that this
  299. 13:46works and the run works. And if we
  300. 13:49change it, you'll see that the
  301. 13:53uh the fist animation works. And we
  302. 13:55change it to sword and dagger. And you
  303. 13:58see that they change as well as the
  304. 14:01animations also work.
  305. 14:06Now
  306. 14:09so now another thing we want to add in
  307. 14:12is the hit reactions because you see
  308. 14:14that when the player gets hit, they
  309. 14:17there's no animation when they get hit.
  310. 14:20So, I also have that linked in the
  311. 14:22description with all the animations, but
  312. 14:25here it's just sword. Reactions 1 2 3 4
  313. 14:295 like
  314. 14:30so. So, if we go to our hit types and we
  315. 14:34go to default, we can make them play the
  316. 14:36animation. So, we'll copy this or we'll
  317. 14:40copy the block break line right here
  318. 14:43and we will go over here and play the
  319. 14:46animations.
  320. 14:48So we will say
  321. 14:52instead of character we can say weapon
  322. 14:56used dot dot dot weapon used dot dot dot
  323. 15:01dot hit
  324. 15:03reactions dot and then we want to
  325. 15:05tworing the current combo string number
  326. 15:08that we're on like so.
  327. 15:11Or we can go over here to
  328. 15:15um reaction animation. Change it to that
  329. 15:17instead of block break just for variable
  330. 15:20purposes. We don't want it saying block
  331. 15:22break when it's really not. And we can
  332. 15:26say local
  333. 15:29assets. We can say assets animations
  334. 15:33do weapon
  335. 15:35used. And then we can say hit
  336. 15:38reactions two
  337. 15:41string combo string number like
  338. 15:43so. And then this should work
  339. 15:47now. So if we play the game you'll see
  340. 15:50the reactions do
  341. 15:52play. So let's dash over
  342. 15:56here like so. And if we switch to
  343. 16:02this, it
  344. 16:05works. Now, another thing I want to
  345. 16:08notice or mention for yall is if you
  346. 16:11recall in the previous video, I was
  347. 16:13saying that you can add in cool effects
  348. 16:16with based on the weapon you string. So,
  349. 16:19in this case, I'm going to add
  350. 16:21a slash effect, a custom slash effect
  351. 16:25based on what weapon you have. And as
  352. 16:28well as over here, I'm going to change
  353. 16:30these sounds to work based on the weapon
  354. 16:33use. So we can say to or weapon use dot
  355. 16:37dot
  356. 16:39dot. Oops. Like
  357. 16:43like so. Weapon use dot dot dot
  358. 16:46hit because the sounds corresponding to
  359. 16:48this are also you have fist. And then
  360. 16:52your number like so.
  361. 16:55Similarly, we'll go over here to our
  362. 16:56blocked and we'll change this to that as
  363. 16:58well.
  364. 17:01Open used dot dot dot like so. And I
  365. 17:05believe in block break there's nothing
  366. 17:06for it.
  367. 17:07Yeah. So now you'll see that the sounds
  368. 17:10actually update based on weapon you're
  369. 17:13using. So for example, we go over
  370. 17:18here. You'll see that we have a normal
  371. 17:20punch sound. But if you switch to
  372. 17:25sword, you see that now the suns are
  373. 17:28updated. And with
  374. 17:32dagger, they're also updated now as
  375. 17:34well.
  376. 17:36Another thing I want to note for y'all
  377. 17:37is that each weapon sort of has a
  378. 17:40different um a different squint cool
  379. 17:43down because the way we scripted the
  380. 17:46system is that all of these weapons are
  381. 17:49reliant on how long the animation is
  382. 17:51like so because you see that animation
  383. 17:53played out length. So, realistically,
  384. 17:56the dagger should be uh significantly
  385. 17:59faster than the fist or sword cuz it's a
  386. 18:02really um versatile and agile weapon.
  387. 18:06But if you want to uh change the length
  388. 18:09of the animation, you can just change it
  389. 18:11within the animation editor to make it
  390. 18:13faster. But now, if we go to hit types
  391. 18:15and we go to default, we can add in a
  392. 18:19new hit effect. So, we can say over here
  393. 18:23weapon used
  394. 18:25And we will go over here to client
  395. 18:26effects default hit.
  396. 18:29Now here we can say if weapon used
  397. 18:32equals fist then we do the normal hit
  398. 18:36effect. So we can go over here and do
  399. 18:39that. Otherwise we can say else if
  400. 18:41weapon used equals equals
  401. 18:45uh let's say sword weapon used equals
  402. 18:48equals dagger. Then we can do a
  403. 18:51different hit effect.
  404. 18:53So you see in effects and core effects I
  405. 18:55have two different type of effects. So
  406. 18:58we can just copy and paste this code and
  407. 18:59we can say core effects and then just
  408. 19:02weapon use dot dot dot slash effect and
  409. 19:05close that. And that should clone it
  410. 19:08based on what type of weapon we have
  411. 19:10like
  412. 19:11so. So now if we play the
  413. 19:15game you will see that we have a slash
  414. 19:18effect rather than normal hit effect.
  415. 19:20So, let's equip our
  416. 19:23fist. You notice that it's still normal,
  417. 19:25but if we equip our
  418. 19:27sword has a new uh slash effect now.
  419. 19:31Similarly with our
  420. 19:35dagger. See that? That
  421. 19:39works. And another thing we want to add
  422. 19:42is let's add
  423. 19:44a let's
  424. 19:47see. We want to I want to introduce to
  425. 19:49you all click detectors. A brief
  426. 19:50overview of what those
  427. 19:52are. So we will add a part in here and
  428. 19:57we'll just call this equip sword or
  429. 19:59something like that. We'll call this
  430. 20:00equip sword. And over here we'll call
  431. 20:03this uh let me turn off this
  432. 20:06move. All right. And over here we can
  433. 20:08call this equip
  434. 20:09dagger. And we can duplicate this and
  435. 20:11call this equip fist. Like so.
  436. 20:15Now, we want to make sure that we anchor
  437. 20:17these like so. And let's just change the
  438. 20:19color so we know what each one is.
  439. 20:25Now, we can add something called a click
  440. 20:27detector in here, which hence the name,
  441. 20:30it just checks whenever you click on
  442. 20:31something. So, we add a script in here.
  443. 20:34We can reference the click detector like
  444. 20:35so. Script. Because that's what the
  445. 20:37click detector is. It's parent or it's a
  446. 20:39child. The script is a child of click
  447. 20:42detector. So, we can do that. click
  448. 20:44detector mouse click and you'll see that
  449. 20:47it gives us a parameter called player
  450. 20:49inside which we can use. So we'll say
  451. 20:53player. Now we can actually give the
  452. 20:56player a
  453. 20:58dagger. So let's go ahead and move all
  454. 21:01of these sort of weapons that we have
  455. 21:03into server
  456. 21:06storage. So let's go ahead and
  457. 21:10just add a folder in here called
  458. 21:12weapons.
  459. 21:16And then we can apparently see her. So
  460. 21:19the main reason I'm doing this is
  461. 21:20because in most games you don't
  462. 21:22automatically spawn with a certain
  463. 21:24weapon or not. Typically you'll have to
  464. 21:26buy it through like maybe gold or
  465. 21:27something. Pay like a,000 gold for a
  466. 21:29sword or a dagger. So this is sort of a
  467. 21:32way to replicate that which you clone
  468. 21:34the weapon whenever you buy it.
  469. 21:37So we go over here and we can
  470. 21:42say local character equals player
  471. 21:45character. Then if character then so
  472. 21:48first off we want to check if the player
  473. 21:50already has this weapon equipped. So we
  474. 21:53also want to check for the backpack and
  475. 21:55we can say this is a backpack instance
  476. 21:58and this is a
  477. 22:01model and then now we can say if
  478. 22:03character find
  479. 22:05child let's say dagger then we want to
  480. 22:08return because we already have a dagger
  481. 22:10equipped or backpack find for child
  482. 22:13dagger then we want to return otherwise
  483. 22:17we'll clone it. So we can just say
  484. 22:19game.server storage.weapons weapons
  485. 22:21dagger clone parent is equal
  486. 22:24to our
  487. 22:26backpack like so. And this should work.
  488. 22:30Similarly, we can just duplicate these
  489. 22:32click detectors into each weapon or each
  490. 22:35part. And then obviously we have to
  491. 22:37change this to fist. And then we have to
  492. 22:39change this to
  493. 22:42sword. So sword and we can also change
  494. 22:45this to sword. And sword.
  495. 22:49So now if we play the
  496. 22:50game, you'll notice that we have nothing
  497. 22:53equipped. However, you can still run.
  498. 22:55You can still dash and things like that.
  499. 22:57However, if we go over here and we
  500. 22:58equipped our dagger or our sword, which
  501. 23:01is this, you'll notice that the model
  502. 23:04automatically gets added, which is what
  503. 23:05we want. And if we equipped it, you'll
  504. 23:08see that we have our
  505. 23:12animation like
  506. 23:14so. And now let's say we want to equip
  507. 23:17our dagger which is right here. We can
  508. 23:21equipped it and then it will
  509. 23:26clone. And if we equipped it, you see
  510. 23:28the animations work. We equipped our
  511. 23:30sword unequipped. It works. Now we go to
  512. 23:34fist. And you know the animation also
  513. 23:37works. So that's good.
  514. 23:40Now another thing we want to do is we
  515. 23:42want to what if the player sells their
  516. 23:45item or it gets destroyed. So let's add
  517. 23:48another part here
  518. 23:50called clear tools or clear
  519. 23:53weapons. Then here we can just
  520. 23:56say we want to loop through the
  521. 23:58character first. So for underscore, tool
  522. 24:01question mark because we don't we don't
  523. 24:03know if it's a tool or not. And
  524. 24:05character get children do. So we can say
  525. 24:07if tool is a tool then we want to
  526. 24:08destroy it.
  527. 24:09Similarly in the backpack we want to do
  528. 24:12the same thing. So tool is a tool then
  529. 24:15tool destroyed like
  530. 24:17so. Now we want to make a way for the
  531. 24:21waded models to the player to also be
  532. 24:24destroyed. So we can make a script in
  533. 24:27here called
  534. 24:29uh tool handler like so. Or yeah tool
  535. 24:32handler.
  536. 24:34I want to note that this tool handler is
  537. 24:36different from this tool loader because
  538. 24:39essentially what the tool handlers do is
  539. 24:41check whenever a tool gets destroyed
  540. 24:43from the player or their backpack. They
  541. 24:45want to destroy anything that's
  542. 24:46associated with it.
  543. 24:49So we'll call S
  544. 24:51handler and we'll establish our
  545. 24:56variables and we can say local function
  546. 24:59player
  547. 25:01added and then we can say player which
  548. 25:04is we know it's going to be player
  549. 25:06players. Added connect function player
  550. 25:08added.
  551. 25:10Now we want to wait for the player to
  552. 25:12load right? So we can say if player doc
  553. 25:14character then otherwise we'll just wait
  554. 25:17for the player to load.
  555. 25:19And now we want to get their
  556. 25:21backpack equals player with a child
  557. 25:24backpack. And we also want
  558. 25:27[Music]
  559. 25:28to
  560. 25:32see and we also want to make a table
  561. 25:34called stored items.
  562. 25:38Like
  563. 25:40so. Uh the reason for stored items is
  564. 25:44essentially what the script will be
  565. 25:46doing is
  566. 25:47checking if a new tool is added to the
  567. 25:50backpack or the character and stored
  568. 25:53items will cast those tools or store
  569. 25:55them cuz we don't want uh a new
  570. 25:58connection to be made that checks for
  571. 26:00when tools destroyed every time the same
  572. 26:02tool is added to the player. So stored
  573. 26:05items table will store that item to
  574. 26:07ensure that we don't make a new
  575. 26:09connection every time.
  576. 26:11So we can make a function called local
  577. 26:14function child added which it's going to
  578. 26:16be an instance and we can say if it's a
  579. 26:21tool
  580. 26:22then if it's not found in stored items
  581. 26:26then we want to create a new connection.
  582. 26:28So child is equal to child destroying
  583. 26:31because we want to check if it's when
  584. 26:33it's
  585. 26:34destroying and we'll say stored items
  586. 26:37child
  587. 26:38disconnect because we want to disconnect
  588. 26:40this uh connection and we want to set it
  589. 26:42to
  590. 26:43no. And then we can say can print
  591. 26:46statement to see if it's actually being
  592. 26:47destroyed. So child player,
  593. 26:51uh item destroyed like
  594. 26:54so. And now we can get out of this get
  595. 26:57out of this whole function and we can
  596. 26:58say backpack child added connect child
  597. 27:01added and we can say for underscore come
  598. 27:04with child in backpack get children do
  599. 27:06and we say child add. So what this is
  600. 27:09doing is that it's checking for when an
  601. 27:12item is added to the backpack and it
  602. 27:14will run this whole function up here or
  603. 27:16if there's already items in the backpack
  604. 27:18it will run the function as well. So
  605. 27:21normally and in here we will do this
  606. 27:25players do and also do player
  607. 27:28addit. As mentioned in the previous
  608. 27:30video this just checks or does a double
  609. 27:32check for if a player is added or when
  610. 27:34the player is already in the
  611. 27:36game. So, if we exit out of here and we
  612. 27:41play the game
  613. 27:45and we go over here to equipped our
  614. 27:48dagger, we see that our dagger is in
  615. 27:51here. And then if we click on clear
  616. 27:54tools, you see the item's destroyed, but
  617. 27:56the dagger model's still there. So,
  618. 27:59using this sort of print sim right here,
  619. 28:01we can destroy any models related to the
  620. 28:03dagger.
  621. 28:05And then also in here, we can Yep, that
  622. 28:08should be good. And we can destroy make
  623. 28:11a comment. We can say destroy related
  624. 28:13destroy
  625. 28:14items such models related to the
  626. 28:20child. So in this case, the name of our
  627. 28:24weapons are dagger back, dagger
  628. 28:25equipped, sword back, sword
  629. 28:28equipped. So we can actually make an
  630. 28:31attribute for all these called weapon
  631. 28:33model. And we set this to true.
  632. 28:36And then in here we can say for
  633. 28:38underscore comma
  634. 28:42um model and character or player
  635. 28:46character get children too and say if
  636. 28:48model get attribute weapon model equals
  637. 28:51true then we can destroy it. So this is
  638. 28:54sort of just like a shortcut to
  639. 28:55destroying the items by using
  640. 28:57attributes and that should work now. So,
  641. 29:00if we get out of this and we play the
  642. 29:04game and let's go ahead and just equip
  643. 29:07all of our weapons that we
  644. 29:09have like so. And if we clear, you'll
  645. 29:12see that all the items are in fact
  646. 29:14destroyed. And that's what we
  647. 29:17want. And we equipped our fist and we
  648. 29:20equipped our dagger again and it'll
  649. 29:24work. All right. Another issue you
  650. 29:27probably noticed about the video is that
  651. 29:28there's sort of like a lag spike
  652. 29:30whenever you equip and unequip your
  653. 29:32weapons. So we will address that now.
  654. 29:36Okay. So we could probably say something
  655. 29:39like if name is not equal to current
  656. 29:41item. Then we want to
  657. 29:44stop. Otherwise we just play the
  658. 29:47animation like so. And we can say
  659. 29:52if not or if anim is playing then we
  660. 29:56want to stop it. Otherwise we just don't
  661. 29:59do anything and we say if not anim is
  662. 30:04playing then we just play the animation
  663. 30:06like so and we can remove this line as
  664. 30:09well. Similarly in here we can say if
  665. 30:12name is not equals to current run a
  666. 30:16value then we can remove these lines up
  667. 30:20here and we can say if anim is playing
  668. 30:24then
  669. 30:27stop.3 otherwise we'll say else if the
  670. 30:31name is equal to the current run then we
  671. 30:33can say if not anim is playing then
  672. 30:36anim and we can remove this right here.
  673. 30:40And that should work. So I also want to
  674. 30:44note the reason for the bug or the
  675. 30:46little lag spike that you see. So if we
  676. 30:49press Ctrl Z all the way, you'll notice
  677. 30:51that we're not checking for if the
  678. 30:53animation is playing or not.
  679. 30:56So essentially what this is doing is
  680. 30:58that we are constantly stopping the
  681. 31:01animation like in a consecutive manner
  682. 31:04without checking if it's actually
  683. 31:06playing or not.
  684. 31:07So by adding in the if animation that is
  685. 31:10playing, it ensures that this little
  686. 31:13method only runs once. Same with this
  687. 31:16right here. This this method should only
  688. 31:18run
  689. 31:19once. So if you play the game,
  690. 31:23let's see if the issue is fixed. Now we
  691. 31:26equipped our items.
  692. 31:35Let's go ahead and
  693. 31:37Move these over a little bit.
  694. 31:41The light spike is still happening.
  695. 31:44All right. So, um, little cut from the
  696. 31:48original video. So, I was mid editing
  697. 31:50and I realized that the issue with the
  698. 31:53lag
  699. 31:55wasn't it wasn't the script. It was
  700. 31:58because I had a camera system called
  701. 32:00Irri, which essentially just causes
  702. 32:04your web or the Iranium webcam just
  703. 32:07causes your whole game to skip um skip
  704. 32:11frames. So yeah, that solution's fixed
  705. 32:13now. And it wasn't an issue with the
  706. 32:15code. It was just an issue with my
  707. 32:18webcam that had installed. So yeah, back
  708. 32:22in the game, you'll see that it's just
  709. 32:24it's false transition. There's no frozen
  710. 32:27or frozen skipped frames or anything
  711. 32:29like that. And yeah, that's back to the
  712. 32:31original video. Now, if we go ahead and
  713. 32:34unequip all of our weapons, you notice
  714. 32:37that all the weapons do get destroyed.
  715. 32:38And if we go ahead and equip all the
  716. 32:41weapons again, you'll see that
  717. 32:44everything works
  718. 32:49fine. Also, okay, now we're in the sort
  719. 32:53of bug fixes part of the combat system.
  720. 32:56So, this is going also going to be a
  721. 32:58part of this episode. And one thing
  722. 33:00you'll notice is that when we're
  723. 33:01blocking, you'll notice that when you
  724. 33:03switch weapons, the animations don't
  725. 33:07change cuz you'll see that, okay, this
  726. 33:10is obviously going to be katana, dagger
  727. 33:13should be that, and fish should be this.
  728. 33:15And another thing you'll note is that if
  729. 33:17I press control, you just stop blocking,
  730. 33:19which we don't really want that. So,
  731. 33:22let's get into that bug fix part. So,
  732. 33:25the first thing we'll do is do the um
  733. 33:27the control
  734. 33:28thing, the block thing. So, in here, we
  735. 33:31can just change this to left control,
  736. 33:33and we can also change this to right
  737. 33:35control. Cuz the reason this was being
  738. 33:38affected before was because we had left
  739. 33:40shift as shift lock, and shift lock
  740. 33:42counts as an is typing thing.
  741. 33:45So, if we do it like that, then it
  742. 33:48should be
  743. 33:49fine. So, let's exit or let's go ahead
  744. 33:52and play the game in
  745. 33:54here. And you'll notice
  746. 33:57that if you equip the
  747. 34:00weapon and press control while you're
  748. 34:03blocking it,
  749. 34:05it doesn't do anything. So, yeah, that's
  750. 34:09good. All right. Now for the next issue
  751. 34:12we had was the the block animations not
  752. 34:16playing the new ones. So in order to fix
  753. 34:19that we can go over here to our
  754. 34:21blocking and we can say okay if not
  755. 34:24character find for shell tool we can add
  756. 34:25on this part and so if we find the tool
  757. 34:29then we can say
  758. 34:32local tool name equals
  759. 34:37character find or local tool is equal to
  760. 34:41character find shot which is a tool and
  761. 34:42we can say local weapon name equals tool
  762. 34:46get attribute
  763. 34:49uh weapon name or whatever or to name my
  764. 34:52fault to name. So we can say tool name.
  765. 35:00All right. And if you recall in the
  766. 35:04comment system, our
  767. 35:07blocking value also has a thing called
  768. 35:09weapon name for an attribute. So we can
  769. 35:11check for our blocking. Say this find
  770. 35:14for shot blocking. We say a blocking
  771. 35:17status
  772. 35:18then local weapon name or yep local
  773. 35:22weapon name equals blocking status get
  774. 35:24attribute weapon name and we can say if
  775. 35:27weapon name is not equal to tool name
  776. 35:30then we want them to stop blocking. So
  777. 35:32we can say remoteblock fire server false
  778. 35:35like so. And we'll just return this one.
  779. 35:40So essentially what this is saying is
  780. 35:42that okay if we find a weapon or our
  781. 35:45blocking status what weapon is not equal
  782. 35:48to the current weapon we have we want
  783. 35:49them to unblock and we want the weapon
  784. 35:52or the block animation to be updated to
  785. 35:54the new one. So if I play the game
  786. 36:00and I go in here and equip we block and
  787. 36:03if we change it to our sword you'll see
  788. 36:06the animation does in fact get updated
  789. 36:08like so.
  790. 36:12And notice that they unblock whenever
  791. 36:14they change. And yeah, that's going to
  792. 36:16be that fix.
  793. 36:18All right, another issue we had is the
  794. 36:20block break
  795. 36:22thing. So you notice that when you get
  796. 36:24block broken, you notice that the block
  797. 36:26animation still
  798. 36:27plays. So we want to fix it. So yeah,
  799. 36:31let's do
  800. 36:33that. And let's go to studio.
  801. 36:38So in order to fix that little issue, we
  802. 36:41can go over here and we can check for if
  803. 36:43the player is
  804. 36:45Thunder. So in here we can
  805. 36:50say if let's go up here and check. Okay.
  806. 36:54So we can say if not cam
  807. 36:57block then we want to return and we want
  808. 37:00to say remote stop block fire server
  809. 37:02false. So, for example, this is for if
  810. 37:05you're stunned or anything like that or
  811. 37:07your guard broken in this case. So, we
  812. 37:08can go over here and say block broken,
  813. 37:11then we want them to stop blocking and
  814. 37:13we want them to be stunned for a
  815. 37:15substantial amount of
  816. 37:16time. So, now if we publish the game, I
  817. 37:21will see y'all in the game and I'll show
  818. 37:23you the
  819. 37:25fix. So, now that I'm in game and I have
  820. 37:28my friend join me to test. You can see
  821. 37:30that. Okay.
  822. 37:32um
  823. 37:34block. All right. So, uh if not can
  824. 37:37block. The reason that this uh is sort
  825. 37:39of broken is because we have the
  826. 37:41blocking status in here called blocking.
  827. 37:44So, it's essentially uh whenever you
  828. 37:46block the status is automatically added
  829. 37:48and it's removed at the same time cuz
  830. 37:50you don't want to do that or you want
  831. 37:53you don't want to block and unblock. So,
  832. 37:55we can remove that and we can check for
  833. 37:58the cam block. So we can say if not can
  834. 38:02block
  835. 38:03and we can say
  836. 38:07and status folder or we can say or
  837. 38:11status folder find blocking. Then
  838. 38:14similarly in here we can say or status
  839. 38:16folder find sh
  840. 38:20blocking and in here we can say we give
  841. 38:23it the same thing.
  842. 38:26So now if we publish the game. All
  843. 38:28right. Now that I'm in game, you can see
  844. 38:30that if we try to block now, you'll
  845. 38:32notice that the blocking animation does
  846. 38:33in fact change. And when you get block
  847. 38:36broken, you'll notice that you can't
  848. 38:37block
  849. 38:38again. Like
  850. 38:40so. So that's
  851. 38:45good. So now if you
  852. 38:49block, you notice that my block
  853. 38:51animation stops playing and I'm stunned
  854. 38:53for a while. So yeah, that's what we
  855. 38:54want. And you see that the block
  856. 38:56animations actually are fixed
  857. 39:00now, you know. So the block stroke
  858. 39:02animation plays and I stop blocking when
  859. 39:05I'm block
  860. 39:06broken. And yeah, that's
  861. 39:09that. All right. So another thing you'll
  862. 39:12notice as um somebody commented in my
  863. 39:15other video is was that the block break
  864. 39:17wasn't working as
  865. 39:19in this animation. the block break
  866. 39:22animation wasn't actually working for
  867. 39:25other players. So, the reason for this
  868. 39:28is because we didn't actually load the
  869. 39:30character animations into the
  870. 39:33player. And as you can see in the block
  871. 39:35dummy, we did load the character
  872. 39:37animations. So, one way we can do that
  873. 39:40is going to our combat system and we can
  874. 39:43say local core folder character wait for
  875. 39:47child core.
  876. 39:49And we can put this in a separate thread
  877. 39:50so it doesn't
  878. 39:52yield. And then we can say local
  879. 39:55animations module equals require core
  880. 39:58folder dot animations like
  881. 40:00so. And then we can say animation
  882. 40:04modules.load anim. And we can load our
  883. 40:07character or our assets.anan animation
  884. 40:10character like
  885. 40:12so. And now we can print our loaded
  886. 40:15animations like so.
  887. 40:21Let's go over here
  888. 40:23and all right. So, the reason this
  889. 40:26errored was because we forgot to add in
  890. 40:28our animator argument. So, we can say
  891. 40:32humanoid.animator. And if we play the
  892. 40:34game, you'll see that the block break is
  893. 40:37actually loaded now. So, that should
  894. 40:40allow well that will allow the character
  895. 40:42to
  896. 40:44play the block break animation when they
  897. 40:45are blocking.
  898. 40:48So, let me get in game and test with one
  899. 40:50of my friends and I'll see you. All
  900. 40:52right, now I'm in the game. So, if I get
  901. 40:54block broken,
  902. 40:57you see that the block break animation
  903. 40:59actually plays. So, yeah, that's what we
  904. 41:00want.
  905. 41:02And let's try it again.
  906. 41:05Let's try it on him. And you'll see that
  907. 41:07the block break animation plays. And
  908. 41:09yeah, that's the fix for that one.
  909. 41:12All right. So, I believe that's going to
  910. 41:14wrap up pretty much episode 7. Meaning,
  911. 41:17today we focused on adding in new
  912. 41:19weapons and mostly just value changing.
  913. 41:22So, I recommend for y'all to just mess
  914. 41:24around with the values once y'all
  915. 41:26completely added it in if you'all want
  916. 41:28to and just see how the animations work
  917. 41:30with each other. And yeah, that's pretty
  918. 41:33much it. Episode 8 will focus on adding
  919. 41:37in mobile and controller compatib
  920. 41:40compatibility to the game. And it'll
  921. 41:42probably be or most likely be the last
  922. 41:45episode of the whole series.
  923. 41:47So yeah.

About this transcript

This page contains the full transcript of [Part7] Easy Roblox Combat System for Beginners | Adding in Weapons & Fixing Bugs by Senko, generated from the public captions YouTube serves with the video. The transcript has 5,886 words across 923 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.