Physics replication for Roblox. Momentum replicates moving models (props, NPCs, vehicles, projectiles, ragdolls) from a server-authoritative simulation to every client over Luau buffers. It includes delta compression, bandwidth budgets, adaptive interpolation, validated client ownership, client-side prediction and lag compensation. Developed by ethandevelopz.
Version 1.1.0 · wire protocol 2
Momentum takes registered models off engine replication and runs its own pipeline:
- Server: each entity is sampled and quantised into a 64-tick history ring. Every client gets its own channel with a dirty set, acknowledged baselines, priority accumulators and a bandwidth token bucket. Updates go out as MTU-bounded packets on an
UnreliableRemoteEvent. - Client: packets are acknowledged, deduplicated and resolved against their baselines. Each entity's states are buffered, then interpolated with an adaptive delay and placed with
workspace:BulkMoveTo. - Lifecycle messages (create, remove, owner, metadata, config) go over one reliable
RemoteEvent. Replaceable state goes over the unreliable one.
See Architecture for the full pipeline and the wire format.
- Delta compression against acknowledged state: records are encoded against the newest state the client acknowledged, using a 16-bit sequence and a 32-bit ack mask, and unchanged fields are omitted. In the test suite a position-only delta record is 10 bytes, and a full record with two sub-parts is 58 bytes.
- Compact quantisation:
- Positions are stored in quanta per stud (64 by default, 128 for vehicles).
- Rotations use smallest-three encoding at 10-bit (about 0.2° maximum error) or 15-bit (about 0.007°).
- Velocities are 16-bit.
- Bandwidth control:
- Each player gets a byte budget per second (16 KB/s default, adapting between 3 and 48 KB/s when packet loss is detected).
- Entities are scheduled by priority, distance and the rate set for their type.
- Interest management: a spatial grid with relevance radii, hysteresis, team or custom visibility filters, and camera focus.
- Sleeping: entities at rest stop sending and wake automatically when they move.
- Interpolation:
Hermite,Cubic,Linear,Ballistic(followsworkspace.Gravity) or your own function. The interpolation delay adapts to jitter and loss, extrapolation is bounded, and corrections are smoothed. - Entity types: presets for
Prop,NPC,Vehicle,Projectile,RagdollandCharacter, and you can register your own. - Proxy mode: the authoritative model simulates in a container that is not replicated, and each client renders a local clone of a template. Many entities can share one
ClientModel. - Client ownership: the owning client simulates and streams its states. The server checks each one for finiteness, displacement against
MaxSpeed, velocity, and an optional custom validator, and sends corrections. Ownership is revoked past a violation threshold. - Client-side prediction: fixed-tick input prediction with server reconciliation, redundant input packets, soft and hard corrections, and input-rate limiting against speed hacks.
- Lag compensation: server-side history queries (
Raycast,QueryRadius) at the moment the player actually saw. - Diagnostics: stats for the server, each player, the scheduler and the client, frame-time percentiles, resource counts, and an on-screen debug overlay.
In Roblox Studio:
- Create a ModuleScript
ReplicatedStorage.Momentumwith the contents ofMomentum.luau. - Inside
Momentum, addClient.luauandServer.luauas ModuleScripts namedClientandServer. - Inside
Momentum, create aModulesfolder and add every file inModules/as a ModuleScript with the same name (ClientChannel,Codec,Config,Debug,Interpolator,NetStats,Prediction,Quantize,Schema,ServerChannel,Signal,SnapshotBuffer,SpatialGrid,StateRing,Transport). - Inside
Momentum, create:Remotes(Folder) containingReliable(RemoteEvent) andUnreliable(UnreliableRemoteEvent)Templates(Folder)
More detail is in Getting started.
Server (ServerScriptService):
local players = game:GetService('Players')
local replicatedStorage = game:GetService('ReplicatedStorage')
local momentum = require(replicatedStorage.Momentum)
momentum.Start()
local crate = momentum.Entity.Register(workspace.Crate, { Type = 'Prop' })
crate:SetPriority('High')
local car = momentum.Entity.Register(workspace.Car, { Type = 'Vehicle' })
players.PlayerAdded:Connect(function(player)
car:SetOwner(player)
end)Client (LocalScript in StarterPlayerScripts):
local replicatedStorage = game:GetService('ReplicatedStorage')
local momentum = require(replicatedStorage.Momentum)
momentum.Start()
momentum.EntityAdded:Connect(function(entity)
print('replicating', entity.Id, entity.Type, entity.Visual)
end)Start() must be called once on each side. On the server it must run before any Register.
| Type | Rate (Hz) | Min rate | Priority | Interpolation | Notes |
|---|---|---|---|---|---|
Prop |
20 | 4 | 1 | Hermite | Defaults: 64 quanta/stud, 10-bit rotation, 400 stud relevance |
NPC |
20 | 6 | 2 | Hermite | 320 stud relevance |
Vehicle |
30 | 10 | 4 | Hermite | 128 quanta/stud, 15-bit rotation, 900 stud relevance |
Projectile |
30 | 30 | 3 | Ballistic | Never sleeps, 1200 stud relevance |
Ragdoll |
20 | 6 | 2 | Hermite | Replicates sub-parts |
Character |
30 | 10 | 3 | Hermite | Observe mode: engine replication renders, Momentum keeps history |
momentum.RegisterType('Boulder', { Base = 'Prop', Rate = 15, SleepDelay = 1.5, RelevanceRadius = 600 })All fields and global settings are listed in Configuration.
Register the same adapter on the server and the client, usually in a shared module, then enable prediction for a player on the server:
momentum.Prediction.Register('HoverPod', {
StateSize = 6,
InputSize = 2,
TickRate = 60,
CaptureState = captureState,
Simulate = simulate,
ToCFrame = toCFrame,
SampleInput = sampleInput,
ValidateInput = validateInput,
})local ok, reason = podEntity:EnablePrediction(player, 'HoverPod')local hit = momentum.LagCompensation.Raycast(player, origin, direction * range)
if hit then
print(hit.Entity.Id, hit.Position, hit.Time)
endQueries rewind to the moment the player saw (now - one-way ping - interpolation delay, clamped to MaxRewind). See Lag compensation.
Everything is in DOCS.md:
| Section | Contents |
|---|---|
| Getting started | Installation, setup, first entities |
| Architecture | Pipeline, modules, modes, wire protocol |
| Server API | Start, Entity.Register, entity methods, signals, stats |
| Client API | Client entities, interpolation, network quality, debug overlay |
| Configuration | Global settings, entity type fields, presets |
| Prediction | Adapters, reconciliation, corrections, stats |
| Lag compensation | View time, Raycast, QueryRadius |
| Guides | NPCs, characters, ragdolls, vehicles, projectiles, custom interpolation |
| Security | Ownership validation, violations, packet limits |
| Performance | Tuning and measured results |
| Testing | Running the test suite and benchmark |
| Troubleshooting | Common problems and known limitations |
| Contributing | Dev setup, pull request checklist, code style |
| Changelog | Release history |
Momentum was verified with 39 specs across five suites:
- CoreSpec: quantisation, codec, buffers, spatial grid, interpolation.
- NetSimSpec: simulated loss, jitter, reordering and duplication.
- MultiClientSpec: 2 to 16 clients, rejoining, forged acks.
- PredictionSpec: reconciliation, corrections, sequence wrap, speed hacks.
- BacklogSpec: 100 to 1000 entities under bandwidth pressure.
The suites drive the real server and client channels through an in-memory network link. All 39 passed in Roblox Studio. The test and benchmark tooling is kept out of this repository.
Highlights from that run:
| Scenario | Result |
|---|---|
| Clean network, 60 entities | 11,214 states verified, 0 mismatches, 60/60 converged |
| 30% loss + jitter + reorder + duplicates, 80 entities | 10,564 states verified, 0 mismatches, 80/80 converged |
| 16 clients (clean, lossy, rejoining, far, narrow, forged acks) | 0 mismatches for every client |
| Prediction on a clean network | 0 corrections, 0 replays |
| Speed hack (inputs sent too fast) | 845 inputs dropped by the server's rate limit |
| 500 entities at the 48 KB/s budget | p95 queue delay 167 ms, p95 position error 3.21 studs |
Full numbers are in Testing and Performance.
Momentum.luau Root ModuleScript and public API (ReplicatedStorage.Momentum)
Client.luau Client runtime (Momentum.Client)
Server.luau Server runtime (Momentum.Server)
Modules/ Internal modules (Momentum.Modules)
DOCS.md Full documentation, contributing guide and changelog
LICENSE.md License
Contributions are welcome. See Contributing, and the Changelog for release history.
Non-Commercial Roblox License. You may use and modify Momentum in your own experiences, including monetised ones. You may not resell it as a standalone product. See LICENSE.md.
- Discord: ethanmracing
- Roblox: ethandevelopz