Lag compensation in the context of first person shooters is a practice of keeping track of the location of hitboxes over a history, and backtracking by half of the shooter's ping when the shooter makes a shot. Some games refer to this as "Favor the Shooter". This method allows for both security in the sense that shots are being validated server side, and the feeling of accuracy from the client in the sense that clients will not have to manually aim ahead based on how laggy their game is. It's recommended that this technique is utilized in conjunction with Client Side Prediction, which gives weapons and other tools a reduction in lag. This module, written in roblox-ts, handles the hard part of lag compensation for you: recording hitbox location and backtracking. The module located in StarterCharacterScripts called Hitbox will keep track of the location of every non-accessory non-tool part of a character, and provide a way of moving these hitboxes to a particular time. You may have to move multiple hitboxes every single hitscan check. Rest assured moving these hitboxes is fairly fast, and as these hitboxes are not replicated to the client they incur no network overhead. That said it's desirable to batch all hitscan requests from a partiuclar character from a particular frame into a single move, to reduce the number of calls to BacktrackTo.
This documentation is incomplete. I may complete it at some point, keep an eye out for it.