Open source combat hitbox module -- knockback included

this is my first shared module on the devforums. this modulescript creates hitboxes for melee games with a single simple function and a lot of customizable arguments to edit hitboxes. you will need to make the part that acts as a hitbox, and the modulescript will do the rest.

i couldnt find many hitbox modules that also had options for flinging or knockback without being really complex, so i decided to make this one myself. it doesn’t have the most consistent code, so you should probably modify it.

just because there are so many arguments to the hitbox function, i’ll explain what they do here
userchar - the character of the player or entity summoning the hitbox, this character won’t be damaged.
sound - the slash/other sound played when the userchar summons the hitbox, useful for weapon swings.
hitsound - the sound played when a character is hit by the hitbox.
hitbox - the hitbox to summon, you need to make the part for this.
rotate - whether or not the hitbox rotates in the direction the player is facing. this is a boolean.
frontalincrease - how far the hitbox summons in front of the player, could be used for ranged weapons that fire in the direction the player is facing, but not up or down.
timelasting - how long the hitbox stays for
lungevelocity - this is how far the userchar should be pushed forward when summoning the hitbox, useful for heavy weapons that would be difficult to swing.
damage - this one is self-explanatory
kb - the knockback value for characters that are hit
kbtime - the amount of time that the knockback lasts.
throw - a boolean that is defaulted to false. this defines whether or not altitude will be used.
altitude - doesn’t do anything if throw is false or nil, this is how far the players should be thrown in the air when inside the hitbox.

the function for spawning a hitbox is
HitboxModule.hitboxSummon(userchar, sound, hitsound, hitbox, rotate, frontalIncrease, timeLasting, lungeVelocity, damage, kb, kbTime, throw, altitude)

this is compatible with some ragdoll systems, but it is not included in the module. you will need to modify it if you want it to ragdoll players.

i have no interest in updating this module or doing fixes, so that’s up to you

HitboxModule.rbxm (2.2 KB)

2 Likes

can you add a video showcasing it please?