Stop losing players to terrible hit registration! Say goodbye to "ghost hits", bullet desync, and players complaining about shots not registering.
Developing fast-paced shooters, melee combat, or action RPGs in Roblox has always faced one major enemy: Network Latency.
Show full description...
This package is a production-ready, 100% headless server-side lag compensation (rollback / rewind) netcode engine built with strict Luau. It allows players to hit targets precisely where they see them on their screens, while maintaining 100% authoritative server security against exploiters.
100% Free & Open — Donations Warmly Welcomed!
This system is released completely free for both commercial and personal projects. There are no locked features, no watermarks, and no paywalls.
- Can't afford to pay? Enter $0 at checkout and enjoy the full package for free!
- Want to support future releases? If this system saves you dozens of hours of complex math and netcode debugging, consider leaving a small tip or donation at checkout to support the creation of more open-source developer systems!
What Problems Does This Solve?
1. Shots not registering
Without lag compensation, players with 100ms+ ping must lead their shots artificially because the server sees characters several studs ahead of where the client rendered them. This engine rewinds hitbox history to the exact millisecond of the shot and validates the hit accurately.
2. Exploits & Silent Aim
Unlike naive systems that blindly trust client hit positions, this engine never trusts the client. The client only sends its timestamp and look direction; the server performs the raycast in the rewound historical world.
3. Zero Physics Jitter or Desync
Hitboxes are only rewound during a synchronous microtask protected by pcall and are immediately restored to their live positions within the exact same frame. Roblox’s physics engine never sees them displaced.
Key Technical Features
- O(1) Ring Buffer: High-performance circular buffer storing character CFrame snapshots without generating garbage collection spikes or memory leaks.
- Sub-Frame Lerp Interpolation: Binary search lookup with linear interpolation between ticks for sub-frame accuracy.
- 100% Headless & Decoupled: Zero UI clutter. Plug it directly into your own custom weapons, bows, knives, magic spells, or guns.
- Universal R15, R6 & NPC Support: Automatically tracks player characters and any NPC models tagged with the TrackedHitbox CollectionService tag.
- Enterprise Anti-Exploit Security:
- Anti-Speedhack: Immediately drops packets with timestamps in the future.
- Max Rewind Window: Rejects stale packets older than the configured limit (1.0 second by default).
- Ping Discrepancy Clamping: Cross-references request age with the real ping of the player to prevent artificial lag toggling.
- Origin Proximity Check: Ensures the shot originated within physical reach of the shooter's server position (prevents silent aim).
- Line-of-Sight Raycast: Detects static world geometry between shooter and target.
- Token Bucket Rate Limiting: Built-in protection against DoS spamming rewind queries.
What is Inside the Download?
Your download includes a tidy zip with:
- LagCompensation_Package.rbxm: The modular package ready to drag & drop into any existing game (ReplicatedStorage and ServerScriptService folders included).
- lag_compensation_place.rbxl: A complete, pre-configured testing place featuring:
- Two active training dummies in Workspace.
- The TestLaserRifle demo weapon in StarterPack with visual laser tracers and console hit feedback.
- Open in Roblox Studio and hit Play (F5) to test instantly!
- README_INTEGRATION: Comprehensive developer guide, API reference, and integration examples.
How to Use It in Your Own Weapons
In your Client Weapon Tool Script:
Grab the synchronized server timestamp using TimeSync.GetServerTime(), then invoke the RequestRaycast RemoteFunction passing the origin, direction, and timestamp. If the server confirms the hit, you can trigger your own sound effects or hitmarkers locally.
In your Server Scripts:
You can also consume the LagCompensator module directly in your custom game systems using LagCompensator.ValidateRaycast() or LagCompensator.ValidateSpatialQuery() for melee attacks and area-of-effect spells.
License & Usage
- License: MIT License.
- Commercial Use: 100% permitted. Feel free to use this in commercial games, commission work, and indie projects.
- Credits: Credit is appreciated but not mandatory.
Leave a Rating!
If you find this system useful, please take 5 seconds to leave a 5-star rating on Itch.io! It helps other developers discover this free tool and keeps the updates coming.