Where to handle hit detection?

I am trying to implement a melee battle system. I used to do EVERYTHING server sided but for me it really reduced player experience, felt sluggish.
I am trying not to rely as much on the server anymore. Note the animations are being played in the client already. This being said I was also wondering where hit detection should be handled:

CLIENT - Would allow for better feeling, although more exploitable. The security checks would be much more important and, still generous, for players with higher ping. Nevertheless, only the server would change the important stuff.

SERVER - Could feel rather sluggish, and reduce player experience due to lag in effects and such. Still, would be much more secure.

BOTH? - Here is the weird one I just thought. What if said detection was handled both sides, each one carrying their own function? Client would play the effects and the server would change stuff accordingly. I feel like, however, it could be much more less optimized in terms of memory waste and such.

I would like to hear your thoughts on this matter.

1 Like

Both would definitely be the better option, don’t rely on one more than the other. If you want a good way to handle hit detection on the client that isn’t easily exploitable I would recommend using Client Cast its a client based hitbox system.

1 Like

As @wowland756 says, you should do both. If you insist on using a homemade system, I recommend having a security timechecker to make sure any laggy attacks are thrown out and have the server only do a rough estimation, for example player position, so people can’t kill someone 300 miles away or through walls. Let it calculate the damage with some guestimation and an equation.

The client should never be trusted but that’s why we have the measure stated above. Use the client to get the target player and the position of the bullet but do NOT let it calculate damage and send it over a replicated event. An exploiter can just force targets and damage values through there without any issue.

1 Like

You should do Server detection for important stuff like damage which would make your game more secure, and use Client sided detection for more unimportant things like special effects, animations, etc.

1 Like

Thanks for sharing the resources. I was planning on using this one, but I can always give that one a shot as well. https://devforum.roblox.com/t/raycast-hitbox-401-for-all-your-melee-needs/374482

Note that this is in a melee combat scenario. Still, I think the method still applies in both situations, right?

Yeah, you will still be determining damage so the specifics if it depends on the body part or not is not a big factor. Just make sure to follow security practices.

1 Like

feels weird asking this a year later, but where should I use the thing, should i cast it in on the client side or server side?