Movement shooter hitreg

hey! so, I’ve been making a movement shooter, which means it’s a shooter but sometimes players go REALLY fast, and that is taking a toll on the hit registration reliability
for the hitbox framework, i tried using this code to sanitize the registration

local part:Part = HitParts[index]

        local HitPosition = HitPositions[index]
        local Distance = HitDistances[index]
        local HitToPartDirection = (part.Position - HitPosition).Unit / 3
        local OffsetHitPosition = HitPosition - HitToPartDirection

        -- validation raycasts
        local ClientPositionValidation = workspace:Raycast(TorsoPosition, (Player.Character.Torso.Position - TorsoPosition).Unit * 100)
        local TargetPositionValidation = workspace:Raycast(OffsetHitPosition, HitToPartDirection * 10, param)
        local validChecks = 0

        -- validation checks
        if (ClientPositionValidation and ClientPositionValidation.Instance:IsDescendantOf(Player.Character)) or (Player.Character.Torso.Position - TorsoPosition).Magnitude < 10 then
            validChecks += 1 else warn("clientPos fail")
        end
        
        if TargetPositionValidation and TargetPositionValidation.Instance:IsDescendantOf(part.Parent) then validChecks += 1 else warn("targPos fail")  end

the clientPos seems to work reliably, but for the target, it seems to always fail if the target is moving quickly, and i dont exactly know why, and i need some help
some extra suggestions on how to sanitize it even more would also be helpful!

2 Likes

I don’t exactly understand how this sanity check is supposed to work, but shouldn’t you just check for line of sight between attacker and target? I guess if they’re moving REALLY fast, you could check where client says they hit the target, look for line of sight there, and calculate leniency based off latency * target move speed.

1 Like

ahh… i think i might have overengineered it, i got too focused on trying to make a validation that wouldnt allow any cheat to go through, so much that i instead made a unreliable code and forgot all that was required was just check for a line of sight, well, thanks anyways! gonna try to update my code

1 Like