How does hitboxes that uses attachment work?

i wanna make a war game when i look at modules like
Raycast Hitbox 4.01: For all your melee needs!
i find it has attachments and i wanna know how does it work

1 Like

It casts rays from the attachments WorldPosition and the rays detect if you hit something. The idea is that you put the attachments on the tool so that when the tool intersects something you can detect it.

To explain in more detail, the idea is to get an extremely precise hitbox that matches where the weapon or whatever is. Unfortunately, just spawning a regular hitbox where the weapon is at a rapid interval is inneffecient and laggy. But instead, we check where a weapon was last interval and where it is currently using a raycast. If the raycast hits something, that means we hit something

The reason why attachments are used is because they retain a certain offset from a basepart while having a readable WorldPosition value; their position in the workspace. Multiple attachments are used to raycast along multiple points to improve accuracy. While you don’t need to explicitly use attachments for this method, it’s a hell of a lot easier to do so.