Hitbox Detects Punching

I used to be average of coding, but over time i had lots of other things to do, so i lost track of coding. Now i came back and i want to make a combat system. I managed to make/weld the custom Hitbox to a Player in “starter player scripts”. Now i want to make Punching and the Hitbox detecting that. How could i possibly do that?

1 Like

loop through:

Hitbox:GetTouchingParts()

then check if the part is parented to a character with a humanoid.

Raycasting. Check out this thread by Swordphin123. It’s a really good and performant module for creating a hitbox for basically anything! It’s highly flexible so you can apply it to basically anything but it also has features like specifically only detecting Humanoids & not detecting the same thing twice. It’s really neat and has received a lot of love and support. Highly recommended.
If you don’t wanna use an open-sourced library / module, I recommend writing your own implementation of it via Raycasting. :GetTouchingParts() or distance-checking works, but it’s very slow and just bad practice. If you got any questions feel free to reply to this. Or you can add me on Discord (malakai ☆#0278 - 216548509212475395).

1 Like

https://developer.roblox.com/en-us/api-reference/class/WorldRoot

4 Likes

Probably the best answer, though I have to mention that even with the “new” OverlapParams, I still prefer normal Region3. OverlapParams is so unreliable for me that I’d rather use .Touched. And we all know how bad .Touched is.

i personally have never had problems with OverlapParams

Could you share details or a bug report on what’s being unreliable with OverlapParams? That way we can fix it.

I’m not sure myself. I’ve taken steps to improve how I handle detecting part collisions, each time I’ve had an issue it left me really confused.

  1. Sometimes, quickly moving an object somewhere where it won’t collide with anything and then quickly back to the original position (where said object collides with another object) causes OverlapParams to not detect a collision, usually only for a couple of frames but that’s enough for someone to be able to abuse a bug (for example, having a collision check for a building game). Sometimes it doesn’t even correct itself.

  2. Then sometimes randomly, it barely works. Though I have to admit, it’s possible that I’ve made a mistake with my script and that’s why it didn’t work, even though the next time I’d test the game everything would work perfectly…

Perhaps the issue is that I’m using it in a big Heartbeat loop? I’m sorry if I shouldn’t post here, I can make a topic on #bug-reports if I need to.

Basically what you can use is GetTouchingParts and a hitbox to detect it. Since everyone is simply EXPLAINING how it works I will be presenting a way you could use it with nocollided characters (as since you know you can’t get nocollided parts with GetTouchingParts.)

local func = script.Parent.Hitbox.Touched:Connect(function() end)
local res = script.Parent.Hitbox:GetTouchingParts()
func:Disconnect()
print(res)

Get a characters arm out of res (table) and then damage the player.

1 Like

thanks, i’ll try my best to youse it all :smiley:

A very accurate, optimized, easy to use, raycast hitbox module.

1 Like