Melee client lag compensation

I am creating a melee script, I have hit detection working which uses region3 to detect if there are any characters in a hitbox area. I want to do lag compensation so laggy clients don’t miss all of their hits. When attacking, a region3 hitbox is created a couple studs in front of the player. My first idea was to get the position of the attackers root part on the client and server and then compare the magnitude between both distances, if the distance is under 1 or 2 studs then it will deal damage to whatever was inside the hitbox.

My second idea was to get the region3 for the client and server hitboxes and then get whatever was inside both the hitboxes, and compare the magnitude of what was hit on the client and server, again, if the distance is under 1 or 2 studs then it will deal damage.

I’m not sure if there’s much of a difference in accuracy between both the methods but I know that comparing the positions of the client and server root would be less performance costly than comparing the positions of all the region3 result magnitudes between the client and server hitboxes.

Would it be worth the accuracy with the region3 method or not?

Using region3s for hitboxes is just a horrible idea. Generating region3s is not optimized at all and don’t even work with orientations. A much better solution is to create a series of attachments across the blade/hitbox of the weapon which all raycast every frame from their last position to their current position to check if they hit a humanoid. Look at this article for more information.