Question about collisions and hitboxes

I am gonna make a combat system pretty soon, I have a script that spawns in a hitbox in the character that is slightly bigger than the characters size and welds it to them.

Now for weapons actually detecting whether they hit the hitbox, do I need to use raycasts, .touched, or any other method? I haven’t done this before so I’m just verifying which method is best for stuff like that. thanks

1 Like

You can use any of these. Note though, for welding hitboxes, it gives up ownership to the player, so they can manipulate those hitboxes maliciously.

I am unaware of the difference between raycasting and .Touched.

1 Like

Do not use .Touched, it is heavily inaccurate. Almost any other method is reliable.

Raycast hitboxes work by constantly checking where an object was last tick and where it is now. This is great for making extremely precise hitboxes, however this also makes it harder to finely turn the size of hitboxes (as the visuals and animation determines how big the htibox is).

Something a little more straightforward is :GetPartsInBox(), which uses a CFrame and size to check all parts within those parameters. Many fighting games have hitboxes that don’t line up with visuals for balance reasons.

The other option is to use magnitude, which just checks how far something is from a certain point. This results in a circle-like hitbox, however it is extremely cheap. Sometimes, precision just isn’t needed.

1 Like

Are there any other alternatives that prevent them from gaining network ownership? I originally was going to use the HumanoidRootPart but I feel like it would be less accurate, as if a sword say hit their arm it wouldn’t be detected I don’t think