[Part5.5] Roblox Combat System for Beginners | Collision Groups & Minor Fixes — Transcript
Full transcript
- 0:00All right, today's going to be sort of
- 0:02episode 5.5. It's also going to be a
- 0:05double upload day, but for 5.5, I'm
- 0:08going to be just doing some minor
- 0:10additions and sort
- 0:11of fixes to the comment system we
- 0:14already have. So,
- 0:18yeah. Right.
- 0:21The first thing I'm going to do is I'm
- 0:23going to add collision groups to the
- 0:25game, which what those are is that they
- 0:28allow certain objects to collide with
- 0:31each other and not collide with each
- 0:33other. So, for example, you'll see that
- 0:35the car my character can sort of collide
- 0:37with these
- 0:38dummies, which could pose a problem in
- 0:41the
- 0:42future for flinging and things like that
- 0:45because if something accidentally
- 0:47happens and I touch the the dummy with a
- 0:51great greater amount of force, then I
- 0:52could get flung on
- 0:56accident. So, a way to avoid that is by
- 0:58adding collision groups.
- 1:01So if I go to model and collision
- 1:05groups, I can add a group called
- 1:09players like so. And so we can say
- 1:12players. We don't want the players to
- 1:14collide with other players. So we can
- 1:15check that off.
- 1:18Now we want to add these
- 1:21um these dummies to the collision group.
- 1:26So we can make a script in server script
- 1:28service called
- 1:31collision handle like so.
- 1:34You can just name this anything you
- 1:35want, but I'm just going to call this
- 1:36collision handle.
- 1:38And another thing in addition with the
- 1:41collision groups is I want to add sort
- 1:43of an I want to organize the workspace a
- 1:46little bit. So, we can add a folder here
- 1:48called
- 1:50world. And I can move all of these
- 1:55dummies to the world. And we'll add
- 1:58another folder here called live. So this
- 2:00handles this folder just contains all
- 2:02the live things like my player, other
- 2:05players, and
- 2:06dummies. So we can add that
- 2:09there. And we can also add a folder
- 2:11called
- 2:13hitboxes and effects like so.
- 2:19Now
- 2:21since we did that, now we need to go to
- 2:23our weapon, our fist weapon, and we need
- 2:26to change the place where we parent the
- 2:28hitbox clone to workspace.orld to hit
- 2:31boxes and change our overlap params
- 2:35too. Like
- 2:38so. So now if we were to play the game
- 2:44and punch,
- 2:46you'll see that the hitbox gets parented
- 2:48to the hitbox folder in here.
- 2:51I can open this quick enough. There we
- 2:52go. Like so.
- 2:56Now, we also want to parent the player
- 2:59to live or the character to live as well
- 3:01because you see we're still in the
- 3:03workspace um folder, not this folder. So
- 3:08to do that, we can go over
- 3:10here and we can start initializing our
- 3:16variables. So we're going to do a player
- 3:18character added function like
- 3:20so. And we can say if player character
- 3:24then and we can add a function down
- 3:27here, a method called character
- 3:31added. So the reason we do both of these
- 3:34is because this checks if the player or
- 3:37the character is already there.
- 3:40Let's say the character is not there and
- 3:41they need to load. So this checks for
- 3:43when the character
- 3:45loads. So that's why we do that. And now
- 3:48we can also add a function called
- 3:49character
- 3:51added. So you see in the character added
- 3:53function there's automatically a
- 3:55parameter passed that Roblox gives you
- 3:58called character. So because of that we
- 4:00can remove the function part right here
- 4:02and just say character added.
- 4:05Now we can also do character add right
- 4:07here.
- 4:09And then we can get run
- 4:12service and we want to wait just a
- 4:15slight second
- 4:16before it parents it parents the
- 4:19character. So we'll do heartbeat wait
- 4:21and we can parent the character to
- 4:23workspace.world.live like
- 4:26so. So if we play the game
- 4:31You'll see that the character isn't
- 4:32paired to the workspace anymore, but
- 4:34he's in live and everything still works
- 4:36as normal. This is just how most games
- 4:39organize their workspace.
- 4:46All right. Now, we'll add collision
- 4:47groups to the character and the dummies.
- 4:51So if you recall earlier, we already
- 4:53made the collision groups in here. But
- 4:55now we need to apply them to everything
- 4:57that's related to the player or a
- 4:59character model.
- 5:02So we can say for underscore,
- 5:06uh v character get descendants do like
- 5:10so. And we let's annotate this because
- 5:12we know it's going to be a model. So we
- 5:13can say get
- 5:15descendants. Oops. There we go.
- 5:18We can say if V is a base part
- 5:22or V is a mesh part
- 5:27or V is a union operation. So we want to
- 5:30want to make sure to check for every
- 5:32possible thing that could have collision
- 5:34group in it. So I'm going to say v.c
- 5:36collision group is equal to players like
- 5:37so.
- 5:41So if we play the game
- 5:45and we open our player
- 5:48Let me click on anything. You can see
- 5:50that our collision group is players.
- 5:55And we also need to make sure that this
- 5:57is also set to players too. So we'll say
- 6:00if V is a part or V is a part.
- 6:05Then
- 6:10so now if we play we'll see that
- 6:12everything in our character is set
- 6:15to players.
- 6:21Like
- 6:22so. And for this we don't we we can
- 6:25ignore the uh this part not being set to
- 6:28players because the hand collide is
- 6:29already off for this. So that'll be
- 6:32fine because it won't collide with it.
- 6:35Anyways, now since we made this players,
- 6:38we also need to make the dummies
- 6:40collision players too cuz this is
- 6:42already set to default. So one way we
- 6:44could do this is just change this to
- 6:46players, which is going to take an
- 6:48extremely long time. Or another way we
- 6:50can do this is
- 6:52say underscore, player.
- 6:57And well before we do that I'm just
- 6:59going to add a character added to
- 7:02this we can say if player character
- 7:07then let's not let's do not repeat
- 7:10yourself um principle. So we can say
- 7:12local function handle character
- 7:15added player like so. Now we can just
- 7:18copy and paste that in there and then we
- 7:20can say handle character
- 7:23added. We also say handle cur
- 7:26here. So the reason we do this is
- 7:29because let's say a player is already in
- 7:31the game and this um method doesn't
- 7:34call. So we can check it twice to make
- 7:36sure that it ensures that the character
- 7:38gets parented and things like
- 7:40that. And now we can handle the
- 7:43collision groups
- 7:44for
- 7:47non-players. So we can say for
- 7:50underscore, vin workspace.world.live
- 7:53live get children
- 7:55do if if not players get player from
- 7:59character V. So it's checking if it's a
- 8:01player or not if the character can
- 8:03correspond to a player in the game. So
- 8:05if it isn't then we can just do
- 8:09this like so.
- 8:16Now we can make a function here called
- 8:19let's
- 8:20see call local function um uh handle
- 8:25collision
- 8:27groups like so and we can call this
- 8:30character and that's going to handle
- 8:32that handle collision groups
- 8:35character and in here we can also say
- 8:38handle collision
- 8:41groups V which V in this case is the
- 8:44character model or the dummies
- 8:48model. So now if we play the game, we
- 8:51get an error. Okay, let's see what this
- 8:54is. Attempt to an external character.
- 8:57Ah, we didn't pass the parameters in
- 8:59here. Okay, now we just add in player
- 9:01here and player here and we should be
- 9:03fine.
- 9:07Let's see what else. If player character
- 9:12handle character
- 9:13added. Here we go.
- 9:16Instead of doing this, we need to say
- 9:18handle closing groups and V.
- 9:24Here we go. Now, if we play the game,
- 9:26we'll see that
- 9:29all these are set to player. And now we
- 9:31we can't collide with these. However, we
- 9:33can still punch these
- 9:35things. Still punch the dummies, but we
- 9:37can't collide with
- 9:38them. So, once again, this will just
- 9:41prevent flinging and unintended things
- 9:43like that.
- 9:47Now, next up is we're just going
- 9:49to make it to where you can't attack or
- 9:52do any actions when you die, cuz we
- 9:55don't want that occurring in the game,
- 9:57obviously.
- 9:59So, and here we can say, let's see,
- 10:07right? We can make a function
- 10:11called is dead. So we say local function
- 10:15is actually no we don't need to do that.
- 10:18We can go to our collision handler
- 10:22and we can let's rename this or we can
- 10:25go to combat service here. There we go.
- 10:26Combat system.
- 10:28And now we can also check for when the
- 10:30character is
- 10:32added.
- 10:33So go down here and we can or we can go
- 10:36right here players. Player addit connect
- 10:39function player
- 10:42or underscore comma player and players
- 10:44get player do.
- 10:48Now we can say character added
- 10:56player character then handle character
- 11:00added
- 11:01[Music]
- 11:03character and
- 11:09Let's just copy this.
- 11:12All right.
- 11:14Now in here we can say local status
- 11:16folder equals character wait for child
- 11:19status
- 11:21commu. We to wait for child because what
- 11:23if the the status folder hasn't actually
- 11:26loaded in yet. We wait for child because
- 11:28we know it's going to be there but we
- 11:29don't know when it's going to be there.
- 11:31So this is going to work. Now we can say
- 11:33local
- 11:34humanoid equals character reference
- 11:36child
- 11:37humanoid and then we can say humanoid
- 11:41died connect function. So he's only
- 11:43going to die once. So we can just say
- 11:45once like so and we can say state
- 11:48service which we have up
- 11:50here. Add
- 11:52state character, dead like
- 11:56so. Now this will handle that.
- 12:01Now, if we play the game,
- 12:05we will see that whenever the character
- 12:07dies, there's going to be a folder added
- 12:09to say called died or
- 12:13dead. Now, we can use this in our input
- 12:16script to just we can say if status
- 12:19folder find dead then return. So, none
- 12:23of these things in here will run if he's
- 12:25dead.
- 12:26So we can say if status folder find shot
- 12:29dead then
- 12:30return or even better we can disconnect
- 12:33this update function. So we can say
- 12:37local render or local step connection
- 12:41equals
- 12:42no step connection equals that and we
- 12:45can say step connection disconnect like
- 12:49so. And step connection equals no like
- 12:52so.
- 12:54So now if we play the
- 12:57game and we start punching, but if we
- 13:00die, you see that we can't punch and we
- 13:02can't block or do anything like that.
- 13:05And if we respawn, we can punch
- 13:08again. Like
- 13:13so. Another thing I'm going to do is I'm
- 13:15going to remove all of these print
- 13:17statements here. So we can just comment
- 13:18all these out.
- 13:28like so.
- 13:34And another thing I'm going to do is add
- 13:38stunning checks to the combat system.
- 13:41So, in the previous video, we didn't
- 13:43actually check if the player was stunned
- 13:45when they're attacking. So we can just
- 13:47add um a comma here and we can say
- 13:50stunned like
- 13:53so and that should be
- 13:56good. Another thing we can do is we can
- 13:59check if the player is stunned once
- 14:01their hitbox starts trying to
- 14:03detect. So we can say if state service
- 14:08check state character, stunned then
- 14:10return. So if they're stunned when they
- 14:14are while the hit box is being made,
- 14:16then we'll just return end because we
- 14:17don't want anything to happen because so
- 14:19because this will cause things like
- 14:22players hitting each other at the same
- 14:24time and things like that. We only want
- 14:25a single player to be able to hit
- 14:27another person once. We don't want them
- 14:29clashing with each
- 14:32other. And we'll check over here. Yep,
- 14:35this shouldn't affect anything for the
- 14:37game. And that should be good.
- 14:44And let's see if there's anything else
- 14:48we want to
- 14:50do. Ah, another thing we want to do is
- 14:52we want to add the block reactions or
- 14:55the block stroke because you notice in
- 14:57the animation resources that I left in
- 15:00the description, there was something
- 15:02called block reaction shrug one and
- 15:04shrug two.
- 15:05So, we're going to use these to actually
- 15:07make the dummy have a sort of animation
- 15:10when they get hit while they're
- 15:12blocking. As you see, right now there's
- 15:14no animation. So, in order to do that,
- 15:16we can go
- 15:19to our hit types and blocked. And we can
- 15:23copy the same code right here that we
- 15:24had for block
- 15:27break, but instead we'll notice that the
- 15:30block reactions is um one and two. So we
- 15:34can randomize between two different
- 15:36animations. So we can let's put this in
- 15:38a different
- 15:40thread and then we can
- 15:43say local random shrug equals
- 15:45math.random one comma 2. So it's going
- 15:48to randomize between one and
- 15:50two. Now we can
- 15:52say weapon used dot dot
- 15:56doblock.reactions dot tworing random
- 16:00stroke and we can play
- 16:01it. Otherwise, we can just say let's add
- 16:05in the assets folder
- 16:07here. We say assets animations
- 16:11dot weapon
- 16:18used.block.reactions
- 16:19shrug one two string one or yeah two
- 16:24string random shrug like
- 16:27so. And over here we also want to fix
- 16:31that we have that shrug and
- 16:34one. Now if we play the game you'll
- 16:37notice that we have an animation
- 16:42added. So if we see what
- 16:45happened animations model module load
- 16:51animation. Ah okay.
- 16:55So in our zombie we also want to load
- 17:00the the fist animations. So animation
- 17:03modules load animations humanoid
- 17:07oops
- 17:09humanoid,
- 17:10dofist. So this will load the animations
- 17:13that we need which contain the shrug and
- 17:15things like that because previously we
- 17:16only loaded the character animation.
- 17:19So let's do the same thing
- 17:22for the other dummies.
- 17:26Oh, these don't have core. Okay, we'll
- 17:28be fine then. All right.
- 17:32So, now you notice if we
- 17:34play, you'll see that we have the shogun
- 17:38emission
- 17:41loading.
- 17:45So, right. All right. Other thing we
- 17:48want to do is we want to make the
- 17:51character be frozen and have a little
- 17:54end lag on the left tip because right
- 17:57now you'll see that
- 17:59the player can freely move in less than
- 18:02one. We don't really want that. We want
- 18:04that. We want them to have a little bit
- 18:05of end lag and for them to be frozen in
- 18:08place on their less than one if we so
- 18:10want to. So in the hit types, we can go
- 18:13to
- 18:14default and we can add on to the last
- 18:17hit thing right here. We can say
- 18:20freezing in place or this will be just
- 18:22called end
- 18:23lag. So we can add a status to this
- 18:29called let's say no no move. And we want
- 18:33this to be about like
- 18:35one one and two10 of a second. And we
- 18:38also add a state here called stun or
- 18:42oops, not check state, add state. And we
- 18:45want to add a state called no attack
- 18:48because we don't want them to be able to
- 18:50attack within this time frame, but we
- 18:52want them to be able to block and things
- 18:54like that. So we'll add something called
- 18:56no
- 18:56punch. However, because we added that
- 18:59state, we also need to add this up here.
- 19:02So we'll say no punch. Then do
- 19:06that. Now we can go to our input and we
- 19:10can add onto our little state handler
- 19:12status updater here and we can say if
- 19:15status folder find first child no
- 19:19punch or we can say no move then final
- 19:23jump power equals zero final walk speed
- 19:25equals zero as
- 19:26well and I also forgot to add the stun
- 19:29status in here so while they're stun of
- 19:32course we don't want them to move or be
- 19:33able to jump so add it like this Another
- 19:37thing I want to note is if you recall,
- 19:39Robux reads their code from top to
- 19:42bottom. So, knowing so, we want to make
- 19:45sure to prioritize which states come
- 19:47first. What I mean by that is if we were
- 19:50to add no move or if we were to add
- 19:53stunned up here because Roblox reads it
- 19:56from the top to bottom, the stun status
- 19:58will be overrided by attacking
- 20:01status. If that makes if that makes any
- 20:03sense. So because of that, we'll want to
- 20:06add stunned as the last sort of state
- 20:10that we want to be updated for the
- 20:12character.
- 20:14Now, if we play the game,
- 20:19you'll see that on the last hit, the
- 20:22player doesn't stop moving because they
- 20:25act didn't hit anything. So that'll
- 20:26that'll be fine.
- 20:28But they hit something. You'll see that
- 20:31they can't move for one or two times of
- 20:33a second. And then they can move
- 20:38again like
- 20:44so. And so that's going to pretty much
- 20:47wrap up this sort of intermission video
- 20:495.5.
- 20:51So mainly today what we did was
- 20:55we fixed it to where you if when you die
- 20:59you won't be able to punch or block or
- 21:00anything like that by adding a folder to
- 21:03status called dead whenever the
- 21:04character dies on the server. And also
- 21:07we added blockstroke animations using
- 21:09the code that we already had for block
- 21:11brick but rather we just added a muff
- 21:13random to randomize between one and two
- 21:16blockstrokes. And we also added a
- 21:19collision handler, which just makes it
- 21:20to where players can't collide with
- 21:23dummies, which can prevent things like
- 21:25flinging and unnecessary issues that we
- 21:28might face in the
- 21:29future. And that pretty much wraps up
- 21:32this video. The next video that will be
- 21:35released today is going to focus on
- 21:37sprinting and dashing, mainly movement.
- 21:40So yeah.
About this transcript
This page contains the full transcript of [Part5.5] Roblox Combat System for Beginners | Collision Groups & Minor Fixes by Senko, generated from the public captions YouTube serves with the video. The transcript has 2,914 words across 471 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.