[Part2] Roblox Combat System for Beginners | Playing Animations — Transcript
Full transcript
- 0:00All right. So, in this video, I'm going
- 0:02to be showing youall how
- 0:04to load and play animations as well as
- 0:07handle connections for animations so
- 0:09they don't cause any memory leaks and
- 0:11things like that, which is going to be
- 0:13handled all in animation modules. And
- 0:16yeah, so at the end of the video, it
- 0:18should look something like this, where
- 0:20you play the animations and it slowly
- 0:22does damage to the player with the
- 0:24hitbox actually relying on an a marker
- 0:28event. So you see that belt hit only
- 0:31starts when it reaches a certain key
- 0:33frame like so.
- 0:36So yeah, hope you enjoy the
- 0:38video. All right, so today I'm going to
- 0:41be showing you how to play animations
- 0:43for the comment
- 0:44system. So in the description I'll have
- 0:47linked a animation dummy for how to use
- 0:50animations from for the fist combat and
- 0:53later we can add different animations
- 0:55for um let's say a sword or katana in
- 0:57the future. which I'll show you on later
- 0:59videos. But let's go to avatar and
- 1:03animation
- 1:04editor. And then we can go to three dots
- 1:07and load. And we can go to
- 1:09L1. Let's remove this for now. All
- 1:12right. So, we play the animation. What I
- 1:15want to note for y'all is animation
- 1:17events, which what they are is they're a
- 1:21certain key frame that you can detect
- 1:24when the animation has reached that and
- 1:27use that in your
- 1:29script. So this going to be mainly used
- 1:31for when you want to start detecting the
- 1:32hit
- 1:33box. So if we go to the frame where we
- 1:36want it to start detecting, we can click
- 1:38on the whole key frame, right click, and
- 1:40do add animation event. And let's call
- 1:43this hit. This is just for you to know
- 1:46what event what the event is called. So
- 1:48you save. And now we can publish to
- 1:51Roblox. Oh, whoops. Let's
- 1:53go. All
- 1:56right. Let's do this. Let's right click
- 1:59and
- 2:03hit. Now we can do publisher blocks. and
- 2:07you can save it as you and click on this
- 2:11little copy thing right here. So, we
- 2:14copy it. Now, if we go to our assets
- 2:17folder that we made, make a folder
- 2:18called
- 2:20animations. Let's get out of this real
- 2:26quick. Animations. And we can duplicate
- 2:29this and make a folder called
- 2:32fist. Now, we can create an animation
- 2:35here. And we can copy or paste the
- 2:38animation ID that we created. We can
- 2:40call this L1, which is just for um your
- 2:43left click one. And let's do the same
- 2:46thing for the rest of the animations. So
- 2:48we go to
- 2:50L2 right here.
- 2:54So we want to start detecting around
- 2:56here.
- 2:59So we can add in mission event pits. So
- 3:02what you should note is that whatever
- 3:04you name your event name should also
- 3:07correspond the to the name that you call
- 3:09in the script. So I'll show youall what
- 3:11that means later but we
- 3:13publish
- 3:15copy and we can duplicate this and paste
- 3:18it.
- 3:30All right. Now that we've finished um
- 3:34adding all the animations in, we can go
- 3:35to our fist script and we can actually
- 3:38start playing the animation. So, first
- 3:41off, what we want to do is let me add a
- 3:43comment here called uh playing
- 3:46animations. Now,
- 3:49ignoring the part where you want to
- 3:51cycle through the swings one through
- 3:53five, I'll show you how to play like a
- 3:54basic animation. So, here we can call
- 3:57for the humanoid like so.
- 4:02humanoid is equal to character.h
- 4:04humanoid. So the reason we can do dot is
- 4:06because we already did find first child
- 4:08here. So and then we can do local
- 4:12animator animator equals
- 4:15humanoidan animator load
- 4:19animation or no humanoid.animator like
- 4:22so. So this is going to be used to
- 4:24actually load the animation. So we can
- 4:27say local animation equals animator load
- 4:31animation and then let's just say L1 for
- 4:34now. So we go to assets.an animations.f
- 4:37this 01 like so. And then always
- 4:40remember to actually start playing the
- 4:42animation like
- 4:44so. Now if we play the
- 4:46game, we can wait for this to
- 4:49[Music]
- 4:51load. So you see that okay the animation
- 4:54is actually playing now which is good.
- 4:56However, we actually want to cycle
- 4:58through
- 4:59this and we also want to
- 5:03uh make the attacking actually
- 5:05correspond with how long the animation
- 5:07is. So, we can let's add a annotation
- 5:10type on here called animation
- 5:12track and we can print the
- 5:17animation.length which essentially is
- 5:20how long the animation is. Yeah, the
- 5:21length of the animation.
- 5:25So, let's go ahead and
- 5:28play 4. All
- 5:38right.
- 5:39So, it prints out zero for animation
- 5:45length. All right. So, the reason for
- 5:47that is because sometimes animations
- 5:50don't load immediately once you call
- 5:53load animation.
- 5:55So a way to get uh a way to get by that
- 5:57is to actually load the animations
- 6:00beforehand. So how we can do that is we
- 6:03can make an animations module in the
- 6:06core for the
- 6:07character like so. So we can call this
- 6:13animations.
- 6:15Now we can go to our tool that we
- 6:20created called fist and add a script in
- 6:22here. called uh tool loader. You can
- 6:26call this whatever you want, but this is
- 6:27mainly going to be for us loading and
- 6:30the animations beforehand.
- 6:33So if we play the
- 6:35game and we
- 6:37wait, we we recall that the fist tool is
- 6:42a part of the backpack, which if we
- 6:45trace it back, it's going to be the
- 6:46player, which is the parent.
- 6:50So knowing this we can call let's call
- 6:52tool
- 6:53loader local
- 6:56player equals script.p
- 7:01parent.parent and after that we can
- 7:05say print player dot print
- 7:10player.name. So you see that it actually
- 7:12prints out my player. So this is useful
- 7:15because we can now
- 7:16do
- 7:18local character equals player character.
- 7:22Oops. Let's do this player player.
- 7:26character or player character added.
- 7:28Wait. So if the player character is
- 7:30there, then we set it to player.
- 7:32character or we wait for the character
- 7:33to be
- 7:34added. And now we can wait for the core
- 7:37folder. Character wait for child core,
- 7:42maf.u. The reason we do math huge is
- 7:44because we don't want the script to time
- 7:46out as I showed before. So we want it
- 7:49because we know the core folder is going
- 7:50to be there. So it is a wait until it
- 7:53actually is present in the
- 7:55character. Now we can go to animations
- 7:57module core
- 7:59folder animations. And always remember
- 8:02to require this or it won't
- 8:04work. So now we can just say
- 8:08module.loaded
- 8:09animations. See what it prints out. Now
- 8:13we can do warn animations module like
- 8:16so. So now if we play the game you can
- 8:20see it warns it and then we can see
- 8:23loaded animations is right
- 8:26there. So in here we want to actually
- 8:29load the
- 8:30animations. So let's make a function in
- 8:33here called
- 8:35function
- 8:37module.load animals like so. And then
- 8:41now we want to say animation
- 8:42modules.load
- 8:46or yeah animation.load enoms
- 8:51and we can say what folder we want it to
- 8:53load. So in this case we want to load
- 8:55the fist animations.
- 8:59So let's go over here. We want to get
- 9:01the replicated
- 9:03storage like so. We want to get the
- 9:06assets
- 9:09folder and we want to get the animations
- 9:11folder or not. We don't need to do that
- 9:14honestly. So we can do animations.fist
- 9:16like so. And then we can say
- 9:21folder and then let's move this up here
- 9:24for organization
- 9:27purposes. We can loop through this whole
- 9:30folder and load all the animations.
- 9:33So the way I want the player to be able
- 9:35to play the animations is something like
- 9:38this. So in order to play it, we can say
- 9:40module.loaded
- 9:42animations your fist.l1 and we can say
- 9:45play like
- 9:47so. Or let's say we have like it's
- 9:50nested inside or like fist and then we
- 9:52can make a swings folder like so. We can
- 9:55say
- 9:56fist.l1 play which I'll I'll probably do
- 10:00this instead. So we'll do it like that.
- 10:02So in order to make this work we have to
- 10:05loop through the animations first
- 10:07underscore an animom and folder get
- 10:10descendants
- 10:12too. Now if animation is an actual
- 10:16animation we want to first off get the
- 10:19full name of the animation. So what I
- 10:21mean by full name is if we go to output
- 10:24we do print gamer replicated
- 10:26storage.etsan animation this.01
- 10:29L1 get full name. We can see it prints
- 10:32out the whole dot
- 10:35plethora which we want it to look
- 10:37exactly like that. So we can say local
- 10:40full name equals anom get full name and
- 10:45we want to actually filter the string so
- 10:47it doesn't include the replicated
- 10:48storage part. So we can do
- 10:53uh full name equals forname
- 10:56splits replicated
- 10:59storage assets
- 11:02animations like
- 11:06so and then
- 11:11yep and then we can say print full name
- 11:13just to see what it actually is now. So,
- 11:16if we were to play the
- 11:23game, we can see that. Okay, there we
- 11:26go. It actually prints out this part. If
- 11:28it starts out 03, so that's good. But
- 11:31there's also a dot right here
- 11:33still. So, we go back over here and we
- 11:36change it to dot. Now, we can say print
- 11:38full name two. Or we can actually set
- 11:41this
- 11:42to two like so. And print full name.
- 11:46So you see that? Okay, nice. This is
- 11:47what we want. We want it to print out
- 11:48the fist swings 0 L 0 L 0 L 0 L 0 L 0 L
- 11:490 L 0 L 0 L 0 L1
- 11:51L2345. And then we can go over here and
- 11:55say module.loaded
- 11:58animations full name is equal to our
- 12:00humanoid load
- 12:02animation which we need to actually
- 12:04assert right
- 12:06here. So we can say local
- 12:09humanoid humanoid equals character
- 12:12childhoid map. because we know the
- 12:14humanoid is going to load anyways.
- 12:17And then we'll make a humanoid an
- 12:19argument
- 12:20here. And same over here we can say
- 12:23humanoid
- 12:25humanoid. Now we can wait for the
- 12:30animator or actually instead of doing
- 12:33humanoid we can say local
- 12:36animator equals humanoid.animator.
- 12:42There we go. Get our animator in
- 12:47there. And then animator, load
- 12:54animation. Make sure to not ignore the
- 12:56case sensitive parts. And then we can
- 13:04say module.loaded loaded animations full
- 13:07name is equal to animator load animation
- 13:12minimum. And now after that once the
- 13:16animations are all loaded we can say
- 13:18okay our tool which is
- 13:20script.parent. So local tool equals
- 13:27script. And we say tool set
- 13:31attribute tool loaded comma true. So the
- 13:34reason I want to do tool loaded and set
- 13:37that attribute to true is because in
- 13:39here we can actually wait for the tool
- 13:41to actually be loaded before we can
- 13:43attack which is just sort of like a
- 13:45prerequisite sanity check to make sure
- 13:47the animations are all fully loaded and
- 13:49well. So in here we can say if not found
- 13:53tool get attribute tool loaded then
- 13:55return n. So it's just going to return
- 13:57if the tool is not actually loaded.
- 14:01Now, if we play
- 14:04the
- 14:05game, well, let's check for the
- 14:08animation. Let's print out all of our
- 14:10loaded
- 14:12animations. Dot
- 14:15loaded
- 14:17items. Animations. Here we
- 14:21go. Now, if we play the
- 14:25game, we can see that nice. All of the
- 14:28animations are fully loaded.
- 14:32So the reason this is good, right, is
- 14:34because if we want to make another
- 14:35katana and we call this like katana or
- 14:37something tool loader, we can actually
- 14:40just load the katana animations as well,
- 14:42which is
- 14:44great.
- 14:46So we go to our fist and then we can
- 14:49actually get the animations folder from
- 14:50the core
- 14:53folder. So local core folder equals
- 14:57character core local animations
- 15:01module. Require corefolder.an
- 15:04animations. Now, if we do print
- 15:06animations module
- 15:08here, let's remove it from
- 15:10here. And then let's exit out of that
- 15:12script, too, cuz that's pretty much all
- 15:14we need for this
- 15:16part. And if we play the game, you'll
- 15:19see that if we attack, it should print
- 15:22out the animations module.
- 15:26As you see, loaded animations has all of
- 15:29our
- 15:30fist. So, finally, we can actually play
- 15:33the
- 15:35animations. So, we can say animation
- 15:37modules fist. L1 play. We can also print
- 15:42the length of it
- 15:46too. That length like
- 15:48so. And if we play the game, wait for it
- 15:52a little bit.
- 15:54Oh, fist.
- 15:56screen. Oh. Uh, whoops. I forgot to
- 16:00reference loaded animation. So, we have
- 16:02to go loaded animations. And then we can
- 16:04actually play it.
- 16:09And you see that we don't have the issue
- 16:11with the zero anymore for it not
- 16:13loading. And it it actually prints out
- 16:14the length.
- 16:16Uh, so for the load animations part, I
- 16:18just messed it up because we actually
- 16:20loaded the animations in this table
- 16:22that's in here.
- 16:25So now that that works, we can also
- 16:28detect for
- 16:31the current swing that we're on now. So
- 16:33we'll make a folder in the fist
- 16:39called
- 16:41configuration. And this will just detect
- 16:43our last swing, our um last combo that
- 16:47we've done and things like that.
- 16:49So in here actually no we don't even
- 16:52need to worry about that. All right. So
- 16:55we got make an int value called last
- 16:57swing and we can make another value
- 17:00called swings or swing number like
- 17:04so.
- 17:06Now let's go over here
- 17:08and add our tool in here as
- 17:13well. There we go.
- 17:16And then
- 17:18now oh yeah another sanity check we can
- 17:21do if tool.name is not equal to
- 17:23script.name then return. So if the
- 17:25actual tool that's uh passed in the
- 17:27argument isn't equals uh the fist then
- 17:29we just return
- 17:31n. But now we can say local
- 17:34configuration folder equals tool finder
- 17:39configuration and not configuration then
- 17:41return end. Oops.
- 17:48Now we can say local last swing. This
- 17:52initial or yeah reference all of our
- 17:55values. Local screen
- 17:59number screen number.
- 18:04Now looking going back to our modules in
- 18:07here the shared data that we can
- 18:11have we can say module
- 18:15dot
- 18:18squ cool down or not even swing cool
- 18:22down we can say combo cool down is
- 18:24equals to 1.5
- 18:25seconds. So after the whole five hit
- 18:28combo is done, we want to add a cool
- 18:31down to how long the player can actually
- 18:33wait before they do a full combo
- 18:36again. So now we can
- 18:40say let's add another value in here
- 18:43called last
- 18:45combo. So if OS.C clock minus
- 18:50our let's initiate last
- 18:55combo minus last combo do
- 19:03value is less than our weapon data
- 19:07dot combo
- 19:09cooldown then return. So if the time
- 19:12pass from the current
- 19:14time minus our last combo time is less
- 19:17than 1.5 seconds then we prevent the
- 19:19player from
- 19:21attacking. And then after that we can
- 19:25[Music]
- 19:26say module combo reset time is equal to
- 19:321.5. So essentially, if the time between
- 19:36our last swing and the swing that we're
- 19:39trying to do is greater than 1.5
- 19:41seconds, we reset the combo back to
- 19:43swing one. So we can say if OSC
- 19:48clock
- 19:50minus last swing value is greater than
- 19:54or equal to weapon data, comma reset
- 19:58time, then we want to reset our swing
- 20:00number to zero.
- 20:03Now we can actually start adding in our
- 20:06swing
- 20:07numbers. So swing
- 20:10number if swing number dot
- 20:15value or first off let's just do this
- 20:18swing number do value plus equals 1.
- 20:20This also adds number to our swing
- 20:23value. And now we can say
- 20:26[Music]
- 20:29if swing number do value is greater than
- 20:32or equal to five then we want to put our
- 20:36last
- 20:37combo. So last combo value equals o
- 20:42clock and we can say last swing. O clock
- 20:47like so. Let's put this outside.
- 20:52And we also want to reset our combo. So
- 20:56swing number value equals zero. Like so.
- 21:02However, now we actually want to
- 21:05um assign the actual animation to play.
- 21:08So local animation to or local true
- 21:12swing
- 21:13number equals uh no. And now we can say
- 21:18true swing number is equal to swing
- 21:20number value. Or if we already set it to
- 21:23zero, we'll just set the true swing
- 21:25number to
- 21:28five is equal to five. Like
- 21:30so. Now we can say local animation to
- 21:35play animation
- 21:37track is equal to Oh, they're all
- 21:40completed at first, but animation
- 21:43modules fist.
- 21:47dot dot dot. We want a two string
- 21:51or L. Two string to true screen
- 21:55number like so. An animation to play. We
- 21:59want to
- 22:01play. Now if we play our game, it should
- 22:07work. We look in
- 22:11our configuration.
- 22:14One, two, three, four, and
- 22:17five. You see that? Now the cordon
- 22:19actually plays as
- 22:20well. One, two, three. Yep. If we
- 22:24unequipped it, it doesn't work. And if
- 22:27we wait 1.5 seconds, so let's say we're
- 22:30on swing three or something. We wait one
- 22:32and a half seconds and it resets it like
- 22:35so.
- 22:38Now if we stop playing the game,
- 22:41we want to actually address the
- 22:43animation markers part now. So remember
- 22:46or if you recall from before, we made a
- 22:49little animation marker called hit on
- 22:52here. So in order to address that, we
- 22:55can say animation to
- 22:58play get marker each signal like so.
- 23:05And we want to make this a
- 23:10connection. So the reason we make this a
- 23:12connection is what if it never actually
- 23:14reaches it because there's an issue with
- 23:15Roblox. We want to find a way to
- 23:17disconnect that so it doesn't cause any
- 23:20memory leaks or anything like that. So
- 23:22let's call this hit connect function
- 23:24like so or once because we only want to
- 23:28call it once, not a lot of times.
- 23:31And then if we go to our animations
- 23:33module, let's make something called uh
- 23:38connections like
- 23:41so now we can
- 23:47say
- 23:50table or we can call
- 23:53this let's remove this and we can say
- 23:57animation modules.loaded loaded
- 23:59animations. And we can also say
- 24:01animation
- 24:04modules.connections whatever our string
- 24:06is up here
- 24:11is equal to connection like so.
- 24:17No.
- 24:20Or instead of doing this, we can
- 24:26say there we
- 24:28go. And instead of just copying and
- 24:31pasting this, we can make this
- 24:33variable. So
- 24:37local local
- 24:39swing name is equal to
- 24:43that swing name. screen name.
- 24:48Over here we can also say screen
- 24:52name. Now we say print hits called
- 24:58like so. And up here we want to actually
- 25:00disconnect any thing that's that's
- 25:02associated with our fist. Let's swing.
- 25:06So if we loop through up here we can say
- 25:16for uh connection
- 25:19name, connection
- 25:22in animation modules connections too. If
- 25:26stringfind connection
- 25:28name,
- 25:31fist.swings, then we want to disconnect
- 25:33it. So we can say connection disconnect.
- 25:36So animation
- 25:40uh connection name
- 25:44disconnect connections connection name
- 25:46is equal to no like
- 25:49so now if we play the
- 25:53game wait for everything to load we can
- 25:56see that okay nice we have it printing
- 25:58out hit called
- 25:59now and if we also print out the
- 26:02connections
- 26:03folder we can see prints animation
- 26:06modules connections
- 26:14you see that okay there is a connection
- 26:15over here and it should be disconnected
- 26:17every time we
- 26:19finish. So for example if
- 26:22we remove
- 26:24that and over here we want to
- 26:28actually make the
- 26:31attacking the same length as our
- 26:34animation length. So animation to
- 26:37play.length and then we want to make our
- 26:39hitbox clone
- 26:42animation.length length like let's say
- 26:44minus or yeah let's keep it like this
- 26:46for now as before like
- 26:52so. So now let's move this over
- 26:55here to our
- 27:00Whoops. There we go.
- 27:05And then paste this in here. And let's
- 27:07move this up a little bit.
- 27:10Move this to where it's around right
- 27:13here.
- 27:18Like
- 27:18so. Or no, cuz we need to establish
- 27:21animation to play. Let's go over here.
- 27:24Right here. Like so.
- 27:29Now when it when the hit is called, we
- 27:33can actually play up hitbox.
- 27:46There we go. And you see that there's a
- 27:48sort delay before you can um before the
- 27:51actual hitbox is called because it's
- 27:53waiting for it to hit that marker.
- 27:57So now if you go up here to your hit
- 27:59dummy, you attack it. Here we
- 28:07go. And then let's go over here
- 28:09[Music]
- 28:11to our anim or our fist up here. And we
- 28:14can do we can do print out our loaded
- 28:19animations. Loaded or connections
- 28:22because we want to see if it actually
- 28:24disconnected.
- 28:33You go. Hit called
- 28:34L3. And you see that every time it calls
- 28:38it, the only connection that's in there
- 28:41is the last swing, which is good because
- 28:43you don't want it to be jumbled up with
- 28:45L3, L2, L1, and things like that.
- 28:49And now
- 28:51that should be it for playing the
- 28:54animations.
- 28:57So in the next video I'm going to show
- 28:59you how to actually stun the character
- 29:01and make a state system. So essentially
- 29:03what a state system would be is if you
- 29:05go to our starter character scripts, we
- 29:08add a folder called status, which this
- 29:11is going to handle all of our states in
- 29:12the game. So let's say we're running,
- 29:14we're dashing, or we are stunned, for
- 29:18example. We add a value called stunned
- 29:20in
- 29:21here. What what the input script will do
- 29:25now is check if you're stunned, and
- 29:26he'll set your walk speed to zero. So
- 29:29for example, we can
- 29:32say status checker like so.
- 29:36And we say if status folder, I'm not
- 29:38going to reference it yet, but if we
- 29:40find for child stun, then we want to set
- 29:43your walk speed or human walk speed to
- 29:45zero like so. So you can't walk is what
- 29:48the state system is going to do. And
- 29:50it's going to do that for attacking.
- 29:51It's going to slow you down a little
- 29:52bit. For blocking, it'll slow you down
- 29:54drastically because you're blocking and
- 29:57things like that.
- 29:59So that should be the end of this video.
- 30:02Thanks for watching and yeah.
About this transcript
This page contains the full transcript of [Part2] Roblox Combat System for Beginners | Playing Animations by Senko, generated from the public captions YouTube serves with the video. The transcript has 3,669 words across 616 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.