HitboxPlus - a hitbox module for combat games
Hey everyone,
I’ve been working on the hitboxes for a combat game, and after rewriting the same stuff a few times I ended up turning it into its own module. It’s free, so I figured I’d share it.
Get the module: https://create.roblox.com/store/asset/135948985088815/HitboxModule-v2
What it does
You give it a shape and a root, and it tells you which characters are inside. That’s the core of it. The rest is the stuff that kept biting me in an actual game:
- A punch hitbox has to follow the player while they lunge, not stay where the swing started.
- Fast attacks can skip right past someone between two checks, especially when the server lags a bit.
- Each target should get hit once per swing, not once per frame.
- Everything has to clean itself up if the player dies or leaves mid-attack.
HitboxPlus deals with all of that, so the code on your end is just “make a hitbox, listen for hits”.
Quick example
local HitboxPlus = require(path.to.HitboxPlus)
local hitbox = HitboxPlus.new("WeldedBox", {
root = character.HumanoidRootPart,
offset = CFrame.new(0, 0, -2), -- 2 studs in front of the character
size = Vector3.new(4, 5, 3),
duration = 0.25,
interval = 0, -- check every frame
IgnoreCharacters = { character },
})
hitbox.OnHit:Connect(function(target, part)
print("hit", target.Name)
end)
hitbox:Start()
Set debug = true if you want to see the box while you’re tuning it.
Hitbox types
Box/Ballcheck once, right away.TimedBox/TimedBallkeep checking for a while, staying where they started.WeldedBox/WeldedBall/WeldedCylinderkeep checking and follow the root around. This is what I use for melee.InPartuses a part’s exact shape,Magnitudechecks real distance from the center, andCylinderis… a cylinder.
Hit modes
Weak(default): each character gets hit once for the whole hitbox. One swing, one hit.Strong: every part, every check.Cooldown: each character at most once every few seconds. Nice for things like a fire zone you stand in.
The part I’m happiest with: sweeping
Welded boxes cover the whole distance they moved since the last check, not just where they ended up. Before this, a fast dash or a laggy server frame would sometimes carry the box straight through someone and the hit just wouldn’t register. Now it does. It’s on by default; turn it off with sweep = false if you don’t want it.
Other options
velocityPredictionaims the box a bit ahead of where the root is moving.dotProductFilteronly counts targets inside a cone, e.g. only in front of you.proportionalsizes the box from the root part’s own size.blacklistPartslets you ignore specific parts, not just whole characters.hitboxIdtags hitboxes so you can cancel them together, like when a player gets stunned mid-combo:
HitboxPlus.ClearHitboxesWithId("Punch_" .. player.UserId)
There’s also GetHitboxesWithId, GetActiveHitboxCount, ClearAllHitboxes, and SetTargetContainer if your characters live in a folder like workspace.LivingThings.
Performance
I tried to keep it cheap, since combat games end up running a lot of these:
- All hitboxes share one Heartbeat, and it disconnects when none are running.
- Checks reuse their tables instead of making new ones every time.
- Cylinders reuse one part, and it won’t show up in your other raycasts or queries.
- Debug mode moves a single box around instead of spawning a new one every frame.
What’s in the package
HitboxPlus- the main moduleSpatialHitbox- the raw queries it’s built on (box, sphere, in-part, magnitude, cylinder, raycast). You can use these on their own too.- It needs
GoodSignalnext to it for theOnHitevent.
Everything is typed. If you pass something wrong, like a missing size, it errors as soon as you create the hitbox, so you catch it while building instead of in the middle of a fight.
That’s pretty much it. If you find a bug or have an idea, let me know below. And if you end up using it in something, I’d love to see it!


