[Part7] Easy Roblox Combat System for Beginners | Adding in Weapons & Fixing Bugs — Transcript
Full transcript
- 0:00All right. So, this is going to be the
- 0:02sort of introduction to episode 7. So,
- 0:05today I'm going to show you how to add
- 0:06in different weapons as well as
- 0:10uh cloning these weapons into your
- 0:11inventory which you can which should be
- 0:13the final product by the end of the
- 0:14video where we have four different
- 0:17blocks which this one clears all your
- 0:19weapons and these ones gives you the
- 0:20dagger, katana, and the fist. And as you
- 0:23can see, whenever it gets added to your
- 0:27uh player uh gives you the weapon model
- 0:29too. And if you clear them, they get
- 0:30destroyed. So let's give me fist and the
- 0:33katana. You see the katana gets added
- 0:35and the dagger also gets added. And we
- 0:37also worked on transitioning between
- 0:39animations. So you see if we're running
- 0:41and we equipped a dagger, then it
- 0:43changes as well as the katana, it
- 0:45changes as well. And if we unequipped
- 0:47everything, you'll see that the
- 0:48animation changes to the
- 0:50default. And we also worked on adding in
- 0:54different uh slash effects and sounds
- 0:56based on the weapon you have. So for
- 0:58example, your
- 0:59fist is just your normal your normal hit
- 1:02sound. But if you switch to dagger, then
- 1:04you have a little dagger
- 1:06sound.
- 1:08So similarly, your or I said dagger
- 1:12earlier and then sword. And similarly,
- 1:14your dagger will have a dagger sound.
- 1:20So, this there's going to be a lot of
- 1:21mini edits in this video, as well as me
- 1:24addressing some bugs that uh I saw in
- 1:28the comment sections from uh previous
- 1:30videos. So, yeah, hope you enjoy the
- 1:32video and please leave a like, um
- 1:35subscribe cuz I do put a lot of effort
- 1:38into these videos and I would really
- 1:39appreciate it. And see youall in the
- 1:41video. All right, welcome to episode 7.
- 1:46So, this is probably going to be the
- 1:47last episode before the end of the
- 1:50series, which is going to be episode
- 1:52eight, marking the end of this. But in
- 1:55this episode, we're going to be focused
- 1:56on adding in two new weapons, or adding
- 1:59multiple weapons if you want to. But in
- 2:02this video, the two weapons we're going
- 2:03to be adding are the sword and the
- 2:08dagger. And all the animations that I
- 2:10have for y'all will be in the
- 2:11description. So, if there's any issues
- 2:14with the animations not loading or
- 2:16anything like that, just comment down
- 2:18and ask for help. And yeah, let's get
- 2:22started. So, the first thing we want to
- 2:24do is we want to duplicate the fist
- 2:27tool.
- 2:29So you'll notice that in all of So first
- 2:33off, if we look up fist, you'll see that
- 2:35the two main scripts that are handling
- 2:37the fist are the weapon data fist and
- 2:41the weapons.fist in our systems folder,
- 2:45as well as the fist
- 2:47tool. So we're going to want to
- 2:50duplicate
- 2:51the tool first. And let's call this
- 2:54sword, like so.
- 2:57and we will open tool loader and you'll
- 2:59see that we still have the assets
- 3:02animation pist. So let me show you how I
- 3:05organize the
- 3:06animations which it should look
- 3:08something like this. So we have our
- 3:11idle and our run animations that contain
- 3:13sword and dagger and sword and dagger
- 3:16corresponding as well as a new
- 3:18animations folder which just organiz
- 3:21which are just organized like this.
- 3:26So, we're going to want to load the
- 3:28sword animations like so. Let's exit out
- 3:31of that. Now that we duplicated that, we
- 3:34can also duplicate the weapons
- 3:37uh fist module and call this sword like
- 3:41so. And we'll check for anything in here
- 3:44called fist.
- 3:46Like so. So, you see that if you see
- 3:49fist, we'll just change this to sword.
- 3:51Oops. And then we will change this to
- 3:53sword.
- 3:55So the reason this works is because the
- 3:57anim the corresponding animations are
- 4:00also called sword. And then so you see
- 4:02score swords swings 01 like so because
- 4:06that's how we created or loaded the
- 4:08animations in our animations module like
- 4:11so because we split the
- 4:13string. Now going back let's go ahead
- 4:17and change all these values. This is
- 4:20just the name of the module. Another
- 4:23thing I forgot to mention is the sounds.
- 4:25So we also have the sim a similar thing.
- 4:28So dagger and sword like
- 4:31so. And we also want to add this to the
- 4:37shared weapon data. So we duplicate
- 4:38this. We can change this to
- 4:41sword like so. And you see block damage
- 4:45damage. We can keep that the same if we
- 4:47want. And then now we can play the
- 4:52game. You see that if we equipped,
- 4:55you'll see the animation starts playing
- 4:56and you see the
- 4:58run like
- 5:05so. However, you'll notice something
- 5:07really funny. There is absolutely
- 5:11um no sword model. So yeah, we're going
- 5:15to need to fix that. Another thing I'll
- 5:16fix is you'll see how the animation
- 5:18abruptly stops. Uh in order to fix that,
- 5:20we can just change out the fade time
- 5:23like so. We can change this to
- 5:26uh let's say three and we can change
- 5:28this
- 5:29three as well as going down here to our
- 5:32animations and we can change this
- 5:35to three as well. So we can change this
- 5:37to three
- 5:39and
- 5:41three. Now we play the game. You'll see
- 5:43that the animations have a slow fade in
- 5:45and they don't just abruptly stop. There
- 5:48we go.
- 5:53You'll see that if
- 5:54we
- 6:01run. All right. Now, we can add in
- 6:04[Music]
- 6:07the the sword model. So, in
- 6:13the resource tab for yall, I have both
- 6:15of the weapon models in
- 6:17here. So, we can duplicate this folder
- 6:21and then we can just parent this to the
- 6:25assets weapons and we just call it
- 6:28weapons
- 6:28folder. And then in our sword, we can
- 6:31now
- 6:34uh create the or we can clone these two
- 6:39sword models. So this is when the sword
- 6:41is going to be on your back or
- 6:43unequipped and this is going to be when
- 6:45your sword is equipped. So Roblox gives
- 6:47you two functions. It gives you tool
- 6:49equipped and it gives you tool
- 6:51unequipped like
- 6:54so. So first off we want to do is we
- 6:56want to actually create or clone these
- 6:59models beforehand. So we can say local
- 7:02back model and we can say local equiped
- 7:04model like
- 7:06so. And then we can go over here and we
- 7:09can reference
- 7:11the
- 7:13weapons weapon
- 7:17models weapons and we can say assets do
- 7:21sword
- 7:23dot we can say weapon models sword dots
- 7:27swordback
- 7:28clone and then we want to weld this to
- 7:31the
- 7:33torso. So say back model.weld world
- 7:37dot part one is equal to our character
- 7:42humanoid part like so. And we just want
- 7:46to parent this to the
- 7:49player. And the same thing for this. We
- 7:51want
- 7:53to w this to the right arm because
- 7:57that's the arm that's going to be
- 7:58equipped when the player starts
- 8:00attacking. Equip model.load Well do
- 8:04parts one is equal to character humanoid
- 8:08or character right
- 8:09arm. We can say equip a model. parent is
- 8:13equal to character. And that should be
- 8:16good. So if we play the
- 8:19game, you'll see that our sword model is
- 8:24on the back. But you'll see that we need
- 8:26to make this equip model transparent.
- 8:31So in order to do that we can just
- 8:33say make a function up here called
- 8:36toggle equipped and we can say
- 8:39boolean. So we can say or we call this
- 8:43is
- 8:44equipped. So is
- 8:46equipped then we want to make the back
- 8:50model
- 8:52transparent and equipped model
- 8:56um visible. Otherwise, we want to make
- 8:59the back model visible and equipped
- 9:02model
- 9:04transparent. So, we go over here and we
- 9:07can
- 9:09say for
- 9:11unerscore, V and back model get
- 9:14descendants
- 9:15too. And we can check if it's a V is a
- 9:20base part or
- 9:21[Music]
- 9:23V is a mesh part.
- 9:28or V is a parts or V is
- 9:31a unit operation then we can say
- 9:34V.transparency is equal to
- 9:37one. As for the equiped model we can
- 9:40just set all of these to zero like
- 9:43so. And similarly to this we can just
- 9:46say zero and we can say
- 9:50one. So we can run this. We can say
- 9:52toggle equipped false because it's not
- 9:55equipped. I'm going to say top equip to
- 9:57true, toggle to false. Like
- 10:00so. Now, if we play the
- 10:04game, you'll see that our weapon model
- 10:06is not visible. If we equipped it, you
- 10:09see that it
- 10:11is. And of course, the animations work
- 10:16now.
- 10:18So, if we change it, you'll see that the
- 10:21animations are good.
- 10:28So
- 10:36all right,
- 10:39next up we want to add in the dagger.
- 10:44So we'll similarly we'll do the same
- 10:46thing. We will duplicate
- 10:50this and then we will also check for
- 10:54anything called sword. Just change this
- 10:56to dagger
- 11:05and we will
- 11:07duplicate
- 11:09our weapon data. Change this to dagger
- 11:12as well.
- 11:14We will create
- 11:15a tool called dagger.
- 11:20And here we just want to do the similar
- 11:22thing, but instead we'll say
- 11:25dagger. And we'll say dagger
- 11:29deck.
- 11:31Dagger dagger
- 11:33equipped. And then that should be good
- 11:35for that. And we also need to change the
- 11:36animation so it loads all of them.
- 11:41So, that should be pretty much it for
- 11:43the
- 11:46dagger. Oh, let's see what the problem
- 11:48is with this. Ah, okay. It's because the
- 11:52models are all different. So, we need to
- 11:53account for that because you'll see that
- 11:55dagger we have a primary part, but here
- 11:58we only have a weld. So, we need to
- 12:00actually go in the primary part and then
- 12:01weld this. So in here we'll just say
- 12:04dagger or back model primary part do
- 12:08handle
- 12:10weld part one equals our human part. And
- 12:14in here we'll just weld this to the
- 12:16right arm like
- 12:17so. So we'll say primary part handle or
- 12:22no weld part one and then we'll
- 12:26say weld.part one like so.
- 12:32Play again. Let's
- 12:36see. Primary part.
- 12:44Let's see. Oh, okay. We didn't set the
- 12:47primary part in here. That's why. So, we
- 12:49want to set this to that. And that
- 12:50should be
- 12:52good. Now, if we play the game, you will
- 12:55see that we have both of our animations
- 12:58or our weapon models in. We see that it
- 13:02looks kind of weird when we're running
- 13:03because it's what it's the humanoid root
- 13:05part. Typically in Roblox or just always
- 13:09in Roblox, the humanoid root part is
- 13:11different from the torso cuz you see
- 13:14this is the torso, but the humanoid root
- 13:16part sort of is in place the whole time.
- 13:19You see that it doesn't move along the
- 13:21torso. So, we just want to weld both of
- 13:24these to the torso. So, we'll say
- 13:26character.rso torso and then we will
- 13:28also say sword or dagger and we'll
- 13:32change this to
- 13:33torso like
- 13:36so. Now if we play the
- 13:38game, you'll see that the weapon
- 13:41actually follows the character. Now if
- 13:43you equipped it, you'll see that this
- 13:46works and the run works. And if we
- 13:49change it, you'll see that the
- 13:53uh the fist animation works. And we
- 13:55change it to sword and dagger. And you
- 13:58see that they change as well as the
- 14:01animations also work.
- 14:06Now
- 14:09so now another thing we want to add in
- 14:12is the hit reactions because you see
- 14:14that when the player gets hit, they
- 14:17there's no animation when they get hit.
- 14:20So, I also have that linked in the
- 14:22description with all the animations, but
- 14:25here it's just sword. Reactions 1 2 3 4
- 14:295 like
- 14:30so. So, if we go to our hit types and we
- 14:34go to default, we can make them play the
- 14:36animation. So, we'll copy this or we'll
- 14:40copy the block break line right here
- 14:43and we will go over here and play the
- 14:46animations.
- 14:48So we will say
- 14:52instead of character we can say weapon
- 14:56used dot dot dot weapon used dot dot dot
- 15:01dot hit
- 15:03reactions dot and then we want to
- 15:05tworing the current combo string number
- 15:08that we're on like so.
- 15:11Or we can go over here to
- 15:15um reaction animation. Change it to that
- 15:17instead of block break just for variable
- 15:20purposes. We don't want it saying block
- 15:22break when it's really not. And we can
- 15:26say local
- 15:29assets. We can say assets animations
- 15:33do weapon
- 15:35used. And then we can say hit
- 15:38reactions two
- 15:41string combo string number like
- 15:43so. And then this should work
- 15:47now. So if we play the game you'll see
- 15:50the reactions do
- 15:52play. So let's dash over
- 15:56here like so. And if we switch to
- 16:02this, it
- 16:05works. Now, another thing I want to
- 16:08notice or mention for yall is if you
- 16:11recall in the previous video, I was
- 16:13saying that you can add in cool effects
- 16:16with based on the weapon you string. So,
- 16:19in this case, I'm going to add
- 16:21a slash effect, a custom slash effect
- 16:25based on what weapon you have. And as
- 16:28well as over here, I'm going to change
- 16:30these sounds to work based on the weapon
- 16:33use. So we can say to or weapon use dot
- 16:37dot
- 16:39dot. Oops. Like
- 16:43like so. Weapon use dot dot dot
- 16:46hit because the sounds corresponding to
- 16:48this are also you have fist. And then
- 16:52your number like so.
- 16:55Similarly, we'll go over here to our
- 16:56blocked and we'll change this to that as
- 16:58well.
- 17:01Open used dot dot dot like so. And I
- 17:05believe in block break there's nothing
- 17:06for it.
- 17:07Yeah. So now you'll see that the sounds
- 17:10actually update based on weapon you're
- 17:13using. So for example, we go over
- 17:18here. You'll see that we have a normal
- 17:20punch sound. But if you switch to
- 17:25sword, you see that now the suns are
- 17:28updated. And with
- 17:32dagger, they're also updated now as
- 17:34well.
- 17:36Another thing I want to note for y'all
- 17:37is that each weapon sort of has a
- 17:40different um a different squint cool
- 17:43down because the way we scripted the
- 17:46system is that all of these weapons are
- 17:49reliant on how long the animation is
- 17:51like so because you see that animation
- 17:53played out length. So, realistically,
- 17:56the dagger should be uh significantly
- 17:59faster than the fist or sword cuz it's a
- 18:02really um versatile and agile weapon.
- 18:06But if you want to uh change the length
- 18:09of the animation, you can just change it
- 18:11within the animation editor to make it
- 18:13faster. But now, if we go to hit types
- 18:15and we go to default, we can add in a
- 18:19new hit effect. So, we can say over here
- 18:23weapon used
- 18:25And we will go over here to client
- 18:26effects default hit.
- 18:29Now here we can say if weapon used
- 18:32equals fist then we do the normal hit
- 18:36effect. So we can go over here and do
- 18:39that. Otherwise we can say else if
- 18:41weapon used equals equals
- 18:45uh let's say sword weapon used equals
- 18:48equals dagger. Then we can do a
- 18:51different hit effect.
- 18:53So you see in effects and core effects I
- 18:55have two different type of effects. So
- 18:58we can just copy and paste this code and
- 18:59we can say core effects and then just
- 19:02weapon use dot dot dot slash effect and
- 19:05close that. And that should clone it
- 19:08based on what type of weapon we have
- 19:10like
- 19:11so. So now if we play the
- 19:15game you will see that we have a slash
- 19:18effect rather than normal hit effect.
- 19:20So, let's equip our
- 19:23fist. You notice that it's still normal,
- 19:25but if we equip our
- 19:27sword has a new uh slash effect now.
- 19:31Similarly with our
- 19:35dagger. See that? That
- 19:39works. And another thing we want to add
- 19:42is let's add
- 19:44a let's
- 19:47see. We want to I want to introduce to
- 19:49you all click detectors. A brief
- 19:50overview of what those
- 19:52are. So we will add a part in here and
- 19:57we'll just call this equip sword or
- 19:59something like that. We'll call this
- 20:00equip sword. And over here we'll call
- 20:03this uh let me turn off this
- 20:06move. All right. And over here we can
- 20:08call this equip
- 20:09dagger. And we can duplicate this and
- 20:11call this equip fist. Like so.
- 20:15Now, we want to make sure that we anchor
- 20:17these like so. And let's just change the
- 20:19color so we know what each one is.
- 20:25Now, we can add something called a click
- 20:27detector in here, which hence the name,
- 20:30it just checks whenever you click on
- 20:31something. So, we add a script in here.
- 20:34We can reference the click detector like
- 20:35so. Script. Because that's what the
- 20:37click detector is. It's parent or it's a
- 20:39child. The script is a child of click
- 20:42detector. So, we can do that. click
- 20:44detector mouse click and you'll see that
- 20:47it gives us a parameter called player
- 20:49inside which we can use. So we'll say
- 20:53player. Now we can actually give the
- 20:56player a
- 20:58dagger. So let's go ahead and move all
- 21:01of these sort of weapons that we have
- 21:03into server
- 21:06storage. So let's go ahead and
- 21:10just add a folder in here called
- 21:12weapons.
- 21:16And then we can apparently see her. So
- 21:19the main reason I'm doing this is
- 21:20because in most games you don't
- 21:22automatically spawn with a certain
- 21:24weapon or not. Typically you'll have to
- 21:26buy it through like maybe gold or
- 21:27something. Pay like a,000 gold for a
- 21:29sword or a dagger. So this is sort of a
- 21:32way to replicate that which you clone
- 21:34the weapon whenever you buy it.
- 21:37So we go over here and we can
- 21:42say local character equals player
- 21:45character. Then if character then so
- 21:48first off we want to check if the player
- 21:50already has this weapon equipped. So we
- 21:53also want to check for the backpack and
- 21:55we can say this is a backpack instance
- 21:58and this is a
- 22:01model and then now we can say if
- 22:03character find
- 22:05child let's say dagger then we want to
- 22:08return because we already have a dagger
- 22:10equipped or backpack find for child
- 22:13dagger then we want to return otherwise
- 22:17we'll clone it. So we can just say
- 22:19game.server storage.weapons weapons
- 22:21dagger clone parent is equal
- 22:24to our
- 22:26backpack like so. And this should work.
- 22:30Similarly, we can just duplicate these
- 22:32click detectors into each weapon or each
- 22:35part. And then obviously we have to
- 22:37change this to fist. And then we have to
- 22:39change this to
- 22:42sword. So sword and we can also change
- 22:45this to sword. And sword.
- 22:49So now if we play the
- 22:50game, you'll notice that we have nothing
- 22:53equipped. However, you can still run.
- 22:55You can still dash and things like that.
- 22:57However, if we go over here and we
- 22:58equipped our dagger or our sword, which
- 23:01is this, you'll notice that the model
- 23:04automatically gets added, which is what
- 23:05we want. And if we equipped it, you'll
- 23:08see that we have our
- 23:12animation like
- 23:14so. And now let's say we want to equip
- 23:17our dagger which is right here. We can
- 23:21equipped it and then it will
- 23:26clone. And if we equipped it, you see
- 23:28the animations work. We equipped our
- 23:30sword unequipped. It works. Now we go to
- 23:34fist. And you know the animation also
- 23:37works. So that's good.
- 23:40Now another thing we want to do is we
- 23:42want to what if the player sells their
- 23:45item or it gets destroyed. So let's add
- 23:48another part here
- 23:50called clear tools or clear
- 23:53weapons. Then here we can just
- 23:56say we want to loop through the
- 23:58character first. So for underscore, tool
- 24:01question mark because we don't we don't
- 24:03know if it's a tool or not. And
- 24:05character get children do. So we can say
- 24:07if tool is a tool then we want to
- 24:08destroy it.
- 24:09Similarly in the backpack we want to do
- 24:12the same thing. So tool is a tool then
- 24:15tool destroyed like
- 24:17so. Now we want to make a way for the
- 24:21waded models to the player to also be
- 24:24destroyed. So we can make a script in
- 24:27here called
- 24:29uh tool handler like so. Or yeah tool
- 24:32handler.
- 24:34I want to note that this tool handler is
- 24:36different from this tool loader because
- 24:39essentially what the tool handlers do is
- 24:41check whenever a tool gets destroyed
- 24:43from the player or their backpack. They
- 24:45want to destroy anything that's
- 24:46associated with it.
- 24:49So we'll call S
- 24:51handler and we'll establish our
- 24:56variables and we can say local function
- 24:59player
- 25:01added and then we can say player which
- 25:04is we know it's going to be player
- 25:06players. Added connect function player
- 25:08added.
- 25:10Now we want to wait for the player to
- 25:12load right? So we can say if player doc
- 25:14character then otherwise we'll just wait
- 25:17for the player to load.
- 25:19And now we want to get their
- 25:21backpack equals player with a child
- 25:24backpack. And we also want
- 25:27[Music]
- 25:28to
- 25:32see and we also want to make a table
- 25:34called stored items.
- 25:38Like
- 25:40so. Uh the reason for stored items is
- 25:44essentially what the script will be
- 25:46doing is
- 25:47checking if a new tool is added to the
- 25:50backpack or the character and stored
- 25:53items will cast those tools or store
- 25:55them cuz we don't want uh a new
- 25:58connection to be made that checks for
- 26:00when tools destroyed every time the same
- 26:02tool is added to the player. So stored
- 26:05items table will store that item to
- 26:07ensure that we don't make a new
- 26:09connection every time.
- 26:11So we can make a function called local
- 26:14function child added which it's going to
- 26:16be an instance and we can say if it's a
- 26:21tool
- 26:22then if it's not found in stored items
- 26:26then we want to create a new connection.
- 26:28So child is equal to child destroying
- 26:31because we want to check if it's when
- 26:33it's
- 26:34destroying and we'll say stored items
- 26:37child
- 26:38disconnect because we want to disconnect
- 26:40this uh connection and we want to set it
- 26:42to
- 26:43no. And then we can say can print
- 26:46statement to see if it's actually being
- 26:47destroyed. So child player,
- 26:51uh item destroyed like
- 26:54so. And now we can get out of this get
- 26:57out of this whole function and we can
- 26:58say backpack child added connect child
- 27:01added and we can say for underscore come
- 27:04with child in backpack get children do
- 27:06and we say child add. So what this is
- 27:09doing is that it's checking for when an
- 27:12item is added to the backpack and it
- 27:14will run this whole function up here or
- 27:16if there's already items in the backpack
- 27:18it will run the function as well. So
- 27:21normally and in here we will do this
- 27:25players do and also do player
- 27:28addit. As mentioned in the previous
- 27:30video this just checks or does a double
- 27:32check for if a player is added or when
- 27:34the player is already in the
- 27:36game. So, if we exit out of here and we
- 27:41play the game
- 27:45and we go over here to equipped our
- 27:48dagger, we see that our dagger is in
- 27:51here. And then if we click on clear
- 27:54tools, you see the item's destroyed, but
- 27:56the dagger model's still there. So,
- 27:59using this sort of print sim right here,
- 28:01we can destroy any models related to the
- 28:03dagger.
- 28:05And then also in here, we can Yep, that
- 28:08should be good. And we can destroy make
- 28:11a comment. We can say destroy related
- 28:13destroy
- 28:14items such models related to the
- 28:20child. So in this case, the name of our
- 28:24weapons are dagger back, dagger
- 28:25equipped, sword back, sword
- 28:28equipped. So we can actually make an
- 28:31attribute for all these called weapon
- 28:33model. And we set this to true.
- 28:36And then in here we can say for
- 28:38underscore comma
- 28:42um model and character or player
- 28:46character get children too and say if
- 28:48model get attribute weapon model equals
- 28:51true then we can destroy it. So this is
- 28:54sort of just like a shortcut to
- 28:55destroying the items by using
- 28:57attributes and that should work now. So,
- 29:00if we get out of this and we play the
- 29:04game and let's go ahead and just equip
- 29:07all of our weapons that we
- 29:09have like so. And if we clear, you'll
- 29:12see that all the items are in fact
- 29:14destroyed. And that's what we
- 29:17want. And we equipped our fist and we
- 29:20equipped our dagger again and it'll
- 29:24work. All right. Another issue you
- 29:27probably noticed about the video is that
- 29:28there's sort of like a lag spike
- 29:30whenever you equip and unequip your
- 29:32weapons. So we will address that now.
- 29:36Okay. So we could probably say something
- 29:39like if name is not equal to current
- 29:41item. Then we want to
- 29:44stop. Otherwise we just play the
- 29:47animation like so. And we can say
- 29:52if not or if anim is playing then we
- 29:56want to stop it. Otherwise we just don't
- 29:59do anything and we say if not anim is
- 30:04playing then we just play the animation
- 30:06like so and we can remove this line as
- 30:09well. Similarly in here we can say if
- 30:12name is not equals to current run a
- 30:16value then we can remove these lines up
- 30:20here and we can say if anim is playing
- 30:24then
- 30:27stop.3 otherwise we'll say else if the
- 30:31name is equal to the current run then we
- 30:33can say if not anim is playing then
- 30:36anim and we can remove this right here.
- 30:40And that should work. So I also want to
- 30:44note the reason for the bug or the
- 30:46little lag spike that you see. So if we
- 30:49press Ctrl Z all the way, you'll notice
- 30:51that we're not checking for if the
- 30:53animation is playing or not.
- 30:56So essentially what this is doing is
- 30:58that we are constantly stopping the
- 31:01animation like in a consecutive manner
- 31:04without checking if it's actually
- 31:06playing or not.
- 31:07So by adding in the if animation that is
- 31:10playing, it ensures that this little
- 31:13method only runs once. Same with this
- 31:16right here. This this method should only
- 31:18run
- 31:19once. So if you play the game,
- 31:23let's see if the issue is fixed. Now we
- 31:26equipped our items.
- 31:35Let's go ahead and
- 31:37Move these over a little bit.
- 31:41The light spike is still happening.
- 31:44All right. So, um, little cut from the
- 31:48original video. So, I was mid editing
- 31:50and I realized that the issue with the
- 31:53lag
- 31:55wasn't it wasn't the script. It was
- 31:58because I had a camera system called
- 32:00Irri, which essentially just causes
- 32:04your web or the Iranium webcam just
- 32:07causes your whole game to skip um skip
- 32:11frames. So yeah, that solution's fixed
- 32:13now. And it wasn't an issue with the
- 32:15code. It was just an issue with my
- 32:18webcam that had installed. So yeah, back
- 32:22in the game, you'll see that it's just
- 32:24it's false transition. There's no frozen
- 32:27or frozen skipped frames or anything
- 32:29like that. And yeah, that's back to the
- 32:31original video. Now, if we go ahead and
- 32:34unequip all of our weapons, you notice
- 32:37that all the weapons do get destroyed.
- 32:38And if we go ahead and equip all the
- 32:41weapons again, you'll see that
- 32:44everything works
- 32:49fine. Also, okay, now we're in the sort
- 32:53of bug fixes part of the combat system.
- 32:56So, this is going also going to be a
- 32:58part of this episode. And one thing
- 33:00you'll notice is that when we're
- 33:01blocking, you'll notice that when you
- 33:03switch weapons, the animations don't
- 33:07change cuz you'll see that, okay, this
- 33:10is obviously going to be katana, dagger
- 33:13should be that, and fish should be this.
- 33:15And another thing you'll note is that if
- 33:17I press control, you just stop blocking,
- 33:19which we don't really want that. So,
- 33:22let's get into that bug fix part. So,
- 33:25the first thing we'll do is do the um
- 33:27the control
- 33:28thing, the block thing. So, in here, we
- 33:31can just change this to left control,
- 33:33and we can also change this to right
- 33:35control. Cuz the reason this was being
- 33:38affected before was because we had left
- 33:40shift as shift lock, and shift lock
- 33:42counts as an is typing thing.
- 33:45So, if we do it like that, then it
- 33:48should be
- 33:49fine. So, let's exit or let's go ahead
- 33:52and play the game in
- 33:54here. And you'll notice
- 33:57that if you equip the
- 34:00weapon and press control while you're
- 34:03blocking it,
- 34:05it doesn't do anything. So, yeah, that's
- 34:09good. All right. Now for the next issue
- 34:12we had was the the block animations not
- 34:16playing the new ones. So in order to fix
- 34:19that we can go over here to our
- 34:21blocking and we can say okay if not
- 34:24character find for shell tool we can add
- 34:25on this part and so if we find the tool
- 34:29then we can say
- 34:32local tool name equals
- 34:37character find or local tool is equal to
- 34:41character find shot which is a tool and
- 34:42we can say local weapon name equals tool
- 34:46get attribute
- 34:49uh weapon name or whatever or to name my
- 34:52fault to name. So we can say tool name.
- 35:00All right. And if you recall in the
- 35:04comment system, our
- 35:07blocking value also has a thing called
- 35:09weapon name for an attribute. So we can
- 35:11check for our blocking. Say this find
- 35:14for shot blocking. We say a blocking
- 35:17status
- 35:18then local weapon name or yep local
- 35:22weapon name equals blocking status get
- 35:24attribute weapon name and we can say if
- 35:27weapon name is not equal to tool name
- 35:30then we want them to stop blocking. So
- 35:32we can say remoteblock fire server false
- 35:35like so. And we'll just return this one.
- 35:40So essentially what this is saying is
- 35:42that okay if we find a weapon or our
- 35:45blocking status what weapon is not equal
- 35:48to the current weapon we have we want
- 35:49them to unblock and we want the weapon
- 35:52or the block animation to be updated to
- 35:54the new one. So if I play the game
- 36:00and I go in here and equip we block and
- 36:03if we change it to our sword you'll see
- 36:06the animation does in fact get updated
- 36:08like so.
- 36:12And notice that they unblock whenever
- 36:14they change. And yeah, that's going to
- 36:16be that fix.
- 36:18All right, another issue we had is the
- 36:20block break
- 36:22thing. So you notice that when you get
- 36:24block broken, you notice that the block
- 36:26animation still
- 36:27plays. So we want to fix it. So yeah,
- 36:31let's do
- 36:33that. And let's go to studio.
- 36:38So in order to fix that little issue, we
- 36:41can go over here and we can check for if
- 36:43the player is
- 36:45Thunder. So in here we can
- 36:50say if let's go up here and check. Okay.
- 36:54So we can say if not cam
- 36:57block then we want to return and we want
- 37:00to say remote stop block fire server
- 37:02false. So, for example, this is for if
- 37:05you're stunned or anything like that or
- 37:07your guard broken in this case. So, we
- 37:08can go over here and say block broken,
- 37:11then we want them to stop blocking and
- 37:13we want them to be stunned for a
- 37:15substantial amount of
- 37:16time. So, now if we publish the game, I
- 37:21will see y'all in the game and I'll show
- 37:23you the
- 37:25fix. So, now that I'm in game and I have
- 37:28my friend join me to test. You can see
- 37:30that. Okay.
- 37:32um
- 37:34block. All right. So, uh if not can
- 37:37block. The reason that this uh is sort
- 37:39of broken is because we have the
- 37:41blocking status in here called blocking.
- 37:44So, it's essentially uh whenever you
- 37:46block the status is automatically added
- 37:48and it's removed at the same time cuz
- 37:50you don't want to do that or you want
- 37:53you don't want to block and unblock. So,
- 37:55we can remove that and we can check for
- 37:58the cam block. So we can say if not can
- 38:02block
- 38:03and we can say
- 38:07and status folder or we can say or
- 38:11status folder find blocking. Then
- 38:14similarly in here we can say or status
- 38:16folder find sh
- 38:20blocking and in here we can say we give
- 38:23it the same thing.
- 38:26So now if we publish the game. All
- 38:28right. Now that I'm in game, you can see
- 38:30that if we try to block now, you'll
- 38:32notice that the blocking animation does
- 38:33in fact change. And when you get block
- 38:36broken, you'll notice that you can't
- 38:37block
- 38:38again. Like
- 38:40so. So that's
- 38:45good. So now if you
- 38:49block, you notice that my block
- 38:51animation stops playing and I'm stunned
- 38:53for a while. So yeah, that's what we
- 38:54want. And you see that the block
- 38:56animations actually are fixed
- 39:00now, you know. So the block stroke
- 39:02animation plays and I stop blocking when
- 39:05I'm block
- 39:06broken. And yeah, that's
- 39:09that. All right. So another thing you'll
- 39:12notice as um somebody commented in my
- 39:15other video is was that the block break
- 39:17wasn't working as
- 39:19in this animation. the block break
- 39:22animation wasn't actually working for
- 39:25other players. So, the reason for this
- 39:28is because we didn't actually load the
- 39:30character animations into the
- 39:33player. And as you can see in the block
- 39:35dummy, we did load the character
- 39:37animations. So, one way we can do that
- 39:40is going to our combat system and we can
- 39:43say local core folder character wait for
- 39:47child core.
- 39:49And we can put this in a separate thread
- 39:50so it doesn't
- 39:52yield. And then we can say local
- 39:55animations module equals require core
- 39:58folder dot animations like
- 40:00so. And then we can say animation
- 40:04modules.load anim. And we can load our
- 40:07character or our assets.anan animation
- 40:10character like
- 40:12so. And now we can print our loaded
- 40:15animations like so.
- 40:21Let's go over here
- 40:23and all right. So, the reason this
- 40:26errored was because we forgot to add in
- 40:28our animator argument. So, we can say
- 40:32humanoid.animator. And if we play the
- 40:34game, you'll see that the block break is
- 40:37actually loaded now. So, that should
- 40:40allow well that will allow the character
- 40:42to
- 40:44play the block break animation when they
- 40:45are blocking.
- 40:48So, let me get in game and test with one
- 40:50of my friends and I'll see you. All
- 40:52right, now I'm in the game. So, if I get
- 40:54block broken,
- 40:57you see that the block break animation
- 40:59actually plays. So, yeah, that's what we
- 41:00want.
- 41:02And let's try it again.
- 41:05Let's try it on him. And you'll see that
- 41:07the block break animation plays. And
- 41:09yeah, that's the fix for that one.
- 41:12All right. So, I believe that's going to
- 41:14wrap up pretty much episode 7. Meaning,
- 41:17today we focused on adding in new
- 41:19weapons and mostly just value changing.
- 41:22So, I recommend for y'all to just mess
- 41:24around with the values once y'all
- 41:26completely added it in if you'all want
- 41:28to and just see how the animations work
- 41:30with each other. And yeah, that's pretty
- 41:33much it. Episode 8 will focus on adding
- 41:37in mobile and controller compatib
- 41:40compatibility to the game. And it'll
- 41:42probably be or most likely be the last
- 41:45episode of the whole series.
- 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.