[Part4] Roblox Combat System for Beginners | Hit Reaction Types — Transcript
Full transcript
- 0:00All right. So, I'm going to be showing
- 0:01you how to make uh the hit types. So,
- 0:05for stunning,
- 0:06for blocked, block break, and things
- 0:10like that. But the first thing I wanted
- 0:12to do is address an issue with
- 0:16the input began, the is typing thing for
- 0:18the user input.
- 0:21So, if we play the game now, you'll see
- 0:24that okay, blocking works, but if you
- 0:26press shift, it just unblocks like so.
- 0:29So a way to fix that
- 0:31is it's because it's saying that
- 0:35uh left shift and right shift count as a
- 0:38sort of game processed event. So if you
- 0:40want to get um bypass that we can say if
- 0:43processed and
- 0:46um change this to
- 0:49inputs and I'm going to say if processed
- 0:53and input.key
- 0:56code is not equal to my key code left
- 0:59shift and input.key key code is not
- 1:04equal to you know my key code right
- 1:06shift
- 1:08then we can say is typing was true
- 1:13so now if we play the game we'll see
- 1:15that okay now if you press shift or
- 1:17anything like that it won't unblock if
- 1:19you start typing then it will so yeah
- 1:22that's
- 1:23that now let's go on to the um hit type
- 1:28sort of um deal for this
- 1:30video So for hit types, it's going to be
- 1:34something
- 1:35like for um we'll make a folder called
- 1:38hit
- 1:40types. And then we can make module
- 1:42scripts depending on what the hit type
- 1:44is. So let's say like okay, you just hit
- 1:46them normally. You call that default.
- 1:50And we can duplicate this. We can call
- 1:51this blocked or block break like so.
- 1:56Let's do um focus on default for now.
- 1:59Let's call this default hit type just
- 2:01for a comment
- 2:03and local hit type and then return hit
- 2:06type.
- 2:10Actually instead of doing this we can
- 2:11just say return function and then add
- 2:14our variables in here.
- 2:16So if we go to
- 2:19our fist
- 2:21system we can actually start requiring
- 2:24these headups.
- 2:26So remember in the previous video where
- 2:27I was like you if you write
- 2:30an if you run code outside of here it'll
- 2:34automatically run once the fist is or
- 2:36once the module is required. So we can
- 2:39say something like requiring head
- 2:42types and now we can say for underscore
- 2:45module and script.parent parent a parent
- 2:48of head types
- 2:49do I'll get children
- 2:52oops if module is a module script
- 2:56then let's say hit types like
- 2:59so weapon
- 3:03type hitit types module name equals
- 3:06require
- 3:08module now if we go down here instead of
- 3:11just making it take damage like so we
- 3:13can
- 3:14say get the status folder
- 3:17Or we can say local state service which
- 3:19you already mentioned up here. So local
- 3:21is blocking equal state service check
- 3:24state your target hit comma
- 3:28blocking like
- 3:30so. Now we haven't added a blocking hit
- 3:33type in here yet. This is going to be in
- 3:35the um future
- 3:37minutes um once we add in the default
- 3:40type. So we can say if is blocking then
- 3:44blocking or like do blocked hit site or
- 3:47something like
- 3:48that. But otherwise we'll just say
- 3:50default hit
- 3:52site. Now for this combat system in
- 3:55particular, I'm not going to worry about
- 3:57sort of thing like a block or posture
- 3:59bar. We're just going to make it to
- 4:00where if you're on the last M1 or last
- 4:02swing, it'll block break.
- 4:05So we can say if swing number do value
- 4:08is greater than or equal to
- 4:10five then last hit which is going to be
- 4:14a block
- 4:15break. However, we don't need to do this
- 4:18up here. We only need to do this if
- 4:19they're blocking it. So before we even
- 4:22add in the block and block break hit
- 4:24types, we can say if swing number value
- 4:28is greater than or equal to five or we
- 4:31can't do that because we already reset
- 4:32it. So we will do true swing
- 4:35number. If true swing number is greater
- 4:38than equal to five then block break.
- 4:42Otherwise we just do the blocked hit
- 4:45type like so. But here we'll just
- 4:49say our weapon type dot hit types
- 4:54default and then we will do the open
- 4:56parenthesis because this is going to run
- 4:58the function because we return the
- 5:00function. But now we need to add in
- 5:02variables or parameters so we know who
- 5:06exactly we're hitting and things like
- 5:07that. So here we can just say okay we
- 5:12want the character we want
- 5:15the target hit things like that and we
- 5:19also want the weapon
- 5:22used. So let's see if we have that up
- 5:25here
- 5:26anywhere. Here we go. Yep. To name. So
- 5:29we can say to name like
- 5:32so. Now we can go over here we can say
- 5:35um attacker we can say target hit,
- 5:39weapon use like
- 5:41so. And we can also if we want it to
- 5:44autocomplete. So we can add annotations
- 5:46in here. So if we go to fist we can say
- 5:49okay we know the character is going to
- 5:51be a
- 5:52model. We know the target hit is also
- 5:55going to be a model. And we know the
- 5:57weapon used is going to be a string.
- 5:58Like
- 5:59so. Now we can make it do damage. So
- 6:03we'll say we'll require
- 6:08the weapon data. So we say weapon data
- 6:11module. Let's get our services
- 6:16first. Local
- 6:18modules. I'm going say weapon data
- 6:20module equals require modules weapon
- 6:23data.
- 6:25Now we can say local found weapon data
- 6:28weapon data module get weapon data
- 6:30weapon used. It found weapon data. Done.
- 6:34Now we can check for the target
- 6:39humanoid. Target hit. Find shot
- 6:42humanoid. If not target humanoid then
- 6:45return
- 6:46end. And now we can make it do damage.
- 6:49So we can say target humanoid take
- 6:52damage. You see it doesn't autocomplete.
- 6:54So we can say annotate as a humanoid.
- 6:57Now it auto completes it for you. Take
- 7:00damage and then we can say go to our
- 7:04thing right here dot damage if we
- 7:06recall. So we can say found weapon data
- 7:09damage like
- 7:11so. And then just for like um we can add
- 7:14a print statement and we can say default
- 7:18hit type reached and we can say comma
- 7:21attacker target hit weapon use like
- 7:24so just so we know that the um the
- 7:28module is actually
- 7:30called. So now let's review the
- 7:34code and yep it should work.
- 7:41So if we play the game,
- 7:44we'll see. Okay, our punching works, our
- 7:46blocking works. If you punch him, you
- 7:48can see that okay, hit type reached and
- 7:51hit dummy
- 7:52fist. So we know that works. Now we can
- 7:56start working on things like our blocked
- 7:58hit type. So if we duplicate this, we
- 8:01can call this
- 8:02blocked. And then after that we can
- 8:05refer back to our fist script and we can
- 8:08say weapon type dot or weapon yeah
- 8:11weapon type hit types block and then we
- 8:14can call it like
- 8:16so to name. Now I want to note like how
- 8:21exactly useful this is because the
- 8:24reason we pass in the weapon use string
- 8:26right is because let's say we want um a
- 8:29unique sort of effect or um something
- 8:34like that. We can say if weapon used
- 8:36equals equals let's say sacred uh sacred
- 8:40katana or something. We can add like a
- 8:43really cool effect if we want to and
- 8:45things like that. Or if we want it to be
- 8:47default, we can say oh else we'll just
- 8:50do a normal normal hit
- 8:53effect. But we're going to do um an
- 8:58effects handler in the next video. But
- 9:00for now, we're just going to work on
- 9:02this. So we can go to
- 9:04blocked. We can say blocked hit type
- 9:08reached. And here we don't want to take
- 9:10any damage. Or if we do, we can go to
- 9:13our weapon data module. We can say chip
- 9:16damage. Essentially chip damage. Um,
- 9:19it's just block damage or we can change
- 9:22this to block damage. There we go. We
- 9:24can say, okay, we want them to take like
- 9:26two damage if they're blocking or
- 9:27something like
- 9:28that. Now, we can just go back to
- 9:31here, go to block, and we can say target
- 9:35humanoid take damage found weapon
- 9:36data.block damage. Like so.
- 9:40And I forgot to add a stun in here. So
- 9:44we can say local state service equals
- 9:48require script. parent state
- 9:52service. Now we can say
- 9:56oops. Let's organize this white space.
- 9:58All right. Add state target
- 10:02hit, stunned. And we can make them
- 10:04stunned for like maybe 4
- 10:06seconds like so.
- 10:10And then we can go to our state service
- 10:15because this might this line might not
- 10:17work because the target hit isn't an
- 10:20actual player and it doesn't have the um
- 10:23the state service folder in it or the
- 10:24status folder in it. So if we want to
- 10:28fix that, we go to state
- 10:30service add state and you'll see it will
- 10:33definitely not work because we set a not
- 10:35status folder then. But if it doesn't
- 10:37find it, we can just say something like
- 10:40uh status folder is equal to instance
- 10:42new folder status folder.name equals
- 10:45status and status folder.parent equals
- 10:48the character or in this case the
- 10:50character would be target hit. So this
- 10:52is going to work now. So if we just get
- 10:55out of that and we go back to blocked or
- 10:58default the stunned should work. So
- 11:01let's go over here and look at it.
- 11:06We play the game. We look in.
- 11:10Let's look at hit dummy.
- 11:13And you'll see that he has a status now.
- 11:15Oops. Let's open it. Yep. You say he's
- 11:18stunned.
- 11:20And after that, let's go to like
- 11:22animation dummy. You'll see that
- 11:23automatically makes a new status folder
- 11:25too. And stun gets
- 11:29added. Now, let's go back to the block.
- 11:32Let's make a new dummy called block
- 11:34dummy. So we can duplicate the hit dummy
- 11:36we have and just call this block
- 11:40dummy like so. And let's just add a
- 11:43script in here so it can play the
- 11:45animation. So we just uh let's just
- 11:47duplicate the auto
- 11:50animation. We call this block
- 11:52anim. Now we can say local block
- 11:56animation equals or no let's say local
- 11:59humanoid script. Uh
- 12:02humanoid block animation humanoid oops
- 12:05do
- 12:07animator humanoid load animation script
- 12:10of block
- 12:11animation
- 12:14play. So yeah that should
- 12:18work. So if we play the
- 12:20game we'll see that the yep the block
- 12:23animation plays but we didn't account
- 12:26for the fact that we need to actually
- 12:27add the block status into the player.
- 12:31So
- 12:33let's go over here and we can add a
- 12:35status folder in here called block
- 12:36called
- 12:43status equals script. parent or another
- 12:47way we could do this is just add a
- 12:48folder called status in here but I'm
- 12:50just going to do it script wise for now
- 12:52because it doesn't really matter in the
- 12:54end and for that we can just add a block
- 12:57status or local
- 12:59blocking instance new folder blocking
- 13:03name equals
- 13:04blocking blocking parent status folder
- 13:06like
- 13:08so now if we play the game
- 13:15And then we open the blocked dummy. See,
- 13:18he has a blocking thing in here. So, we
- 13:21hit him. We'll see that. Okay, we have
- 13:23blocked hitype breached.
- 13:27Yep. Like
- 13:29so. But now we actually have to work on
- 13:32the block
- 13:34break because that's how we scripted it
- 13:37for it to block break on the last swing.
- 13:40So we can duplicate the blocked module
- 13:44and we can call this block break and we
- 13:46can duplicate this code and say block
- 13:50break like
- 13:52so. Now we don't want the block break to
- 13:55actually make them take damage. We just
- 13:56want them to be stunned for a long time.
- 13:59So we can say block break hits breached
- 14:02and we can
- 14:03say get the state service in here.
- 14:08Now we can say local or state service
- 14:11add state a target hit comma stunned and
- 14:16we want it to be stunned for around 1.5
- 14:18seconds. We can also add another state
- 14:20called block
- 14:22broken for
- 14:241.5. There we go. And notice how these
- 14:27two durations are the
- 14:29same. And we can also play the block
- 14:32break animation.
- 14:34So
- 14:37one way we can do this is we can use
- 14:39load
- 14:40animation on the animator.
- 14:43Oops. Animator
- 14:46or we can make a animations module in
- 14:50here. So we can account for two of these
- 14:53things. So we can say um as you'll see
- 14:57that in our character we have the core
- 15:00and then
- 15:01animations. So we'd also need to
- 15:03duplicate the core and add that into
- 15:04there like so. Oh, we're going to remove
- 15:07the input because we don't want the
- 15:09dummy to be accessing client script. So
- 15:12see
- 15:13this and after that we can go over here
- 15:18we can say if target hit find for child
- 15:21core then local animations
- 15:27module equals
- 15:29require target hit.core record
- 15:32animations and we can say
- 15:34animations.loaded
- 15:36animations. Let's remove the block.
- 15:38Let's move the block break to just the
- 15:40um normal animations.
- 15:42So we can just add a new folder in here
- 15:44called
- 15:46character like so
- 15:49and we can just go over here block
- 15:51break. So go to animations and we can
- 15:54say
- 15:56character.block break and we can say
- 15:59play. Otherwise, we'll just load the
- 16:01animation normally. So, we can say local
- 16:04animator target humanoid uh
- 16:08animator or we can say find for child
- 16:11animator cuz what if it's not
- 16:13there? So, if
- 16:15animator then we can say local block
- 16:20break equals animator load animation.
- 16:24Let's add an autocomplete to this. So,
- 16:26annotate this like so.
- 16:29So now we can call that
- 16:31animation and then we can
- 16:33say let's add an assets variable in
- 16:38here. We can say
- 16:40assets dot character.block break oops
- 16:44animations character blockbreak and we
- 16:47can say block break animation play like
- 16:49so. So this is going to account for the
- 16:51fact that okay there's a core and an
- 16:53animations module then we play the
- 16:55normal animation. We don't need to load
- 16:56it. But if there's not, we'll just um
- 16:59load it and we'll play
- 17:02it. So in the script over here, we can
- 17:05just require
- 17:06the animations
- 17:09module. Require
- 17:12script.parent.core animations. We say
- 17:15animation modules load anim. And we can
- 17:18say gamer to assets animations
- 17:22character. Like so.
- 17:24Now, if we just get out of that script
- 17:27and we go over here,
- 17:30we'll also want the dummy to reblock
- 17:32after they're done block broken. So, we
- 17:35can replicate
- 17:36that. So, we can
- 17:38say we can say while true
- 17:43do or we can say yeah while true
- 17:49do test. Okay, cuz remember if you don't
- 17:52add a test weight, it's just going to
- 17:54spam the same thing multiple times and
- 17:56it's going to cause the script to break
- 17:58and output something like script exhaust
- 18:00time. So add a wait and we'll
- 18:04say if status folder find first child
- 18:07block broken or status folder find for
- 18:11child stunned then we can say
- 18:14uh blocking
- 18:18destroy otherwise we'll just reblock him
- 18:20and we also want to stop the animation
- 18:24so block animation stop. Otherwise,
- 18:28we'll just create a new blocking
- 18:30instance. So, let's make this function
- 18:32create blocking instance like
- 18:36so. And then we can just call that
- 18:38function. Remember the do not repeat
- 18:40yourself. So, we just call the function
- 18:42here. And we'll also
- 18:45[Music]
- 18:48say_, V inside folder, which should do
- 18:52v.name equals then v
- 18:55destroy or v.name name equals blocking
- 18:57my false.
- 18:59Otherwise, we'll just say create
- 19:01blocking instance. And we want to play
- 19:02the animation.
- 19:05And then over here, if since we don't
- 19:07want it to spam play the animation, we
- 19:09can say if block
- 19:10animation is playing, then we want to
- 19:14stop. Otherwise, we can say
- 19:18if block animation if not block
- 19:20animation is
- 19:23playing, then block animation play.
- 19:27And we don't want to spam create a ton
- 19:28of blocking instances. So we can say if
- 19:31not satisfer find for shot blocking.
- 19:34Then we do
- 19:35this. And there we go. That's this is
- 19:38going to allow for the dummy to reblock
- 19:40after it's been
- 19:41guardbroken. So if we play the game,
- 19:44we'll see an error. Let's see.
- 19:48Attempt to index nil with get
- 19:50descendants. Oh, forgot to fill in the
- 19:52animator variable. Okay. Or parameter.
- 19:55So, if we go over here, we'll see that
- 19:59right here. We can go to script.parent.h
- 20:03humanoid.an animator like so. And let's
- 20:07just go over here.
- 20:09We'll do all this. Move this up
- 20:12here. Remove all of this. So, we can
- 20:15instead of doing script apparent
- 20:16humanoid, we can just say humanoid like
- 20:19so.
- 20:21And let's go over here.
- 20:27game and you'll see that it works. So,
- 20:29he's blocking and we can see that. Okay.
- 20:33And then he's guard
- 20:35broken. And then if we He's doing a lot
- 20:39of damage. Hold
- 20:41on. Let's go to our blocked site. Block
- 20:46damage.
- 20:54Let's see.
- 20:59Oh,
- 21:01okay. So, yeah, interesting. Well, let's
- 21:05just remove this part of the script. And
- 21:07there we go. It should be fixed.
- 21:09Okay. Now, if we go back to the block
- 21:12and let's just remove all these prints
- 21:14over here. Now, it should work. So,
- 21:17let's just go over here to fist. We'll
- 21:19change this to two again.
- 21:21And then if we play the game, it should
- 21:24be fine now.
- 21:26Yep, there we go.
- 21:28And you see that he block breaks for a
- 21:30little bit and then he goes
- 21:33back like
- 21:35so. So let's increase the block break
- 21:38time or no, let's make him reblock after
- 21:42a little bit. So we can
- 21:44say if not satisfied or find shot
- 21:46blocking then we can say
- 21:48test weight one and make him reblock.
- 21:59There we go. Now we wait one and now we
- 22:02rebu like
- 22:04so. And in that time frame, we can do,
- 22:07you see how it's normal damage, but if
- 22:09you
- 22:10reblocks, you see that? Yep. Works.
- 22:14And if we look at his status folder, you
- 22:17see it's only a single
- 22:19blocking, which works because test.wait
- 22:22will yield this whole loop until this
- 22:25part is
- 22:26called. And yep, that's that.
- 22:34So, that's going to be pretty much it
- 22:36for this episode. Mainly, I just wanted
- 22:38to focus on adding in new hit types and
- 22:42showing y'all how
- 22:43to incorporate them in the script. So,
- 22:46you see that we made it okay, we block
- 22:48on the last M1. And otherwise, we do a
- 22:50blocked effect. And then if none of
- 22:54those apply, then we just do the normal
- 22:55hit
- 22:56type. And it's very easy to configure
- 22:59them because if we want to have a unique
- 23:01functionality, we can say weapon use
- 23:03blah blah blah like I mentioned earlier.
- 23:07And you see that block damage, we have
- 23:09just the default damage over here. And
- 23:12then here I made I showed you how
- 23:16to if the if there's no animation module
- 23:20in here, then we just load the
- 23:22animation, we play it. Otherwise, we
- 23:25just get the animations module and then
- 23:27we play
- 23:28it. So,
- 23:31yeah. So, that's going to wrap up this
- 23:33video. The next video is going to be
- 23:35released later today as well, and it's
- 23:38going to focus on adding visual effects
- 23:40to our combat system, cuz right now, the
- 23:43combat system honestly looks extremely
- 23:45bland, and we don't want it looking like
- 23:49this when we release it.
- 23:52So, we will add visual effects like a
- 23:56little blocked effect and a block break.
- 23:57Sort of like a dizzy I'm spinning around
- 24:00effect, a hit effect and things like
- 24:03that. So, yeah. Hope you enjoyed the
- 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.