Below is a production-grade, server-authoritative anti-cheat framework that combines every practical detection vector currently known in the Roblox ecosystem.
It is intentionally modular (drop-in folders / ModuleScripts) and performance-tuned (O(1) checks, deferred event queues, throttled scans).
Nothing here touches the client’s memory or uses any undocumented APIs—everything is 100 % compliant with Roblox ToS.
────────────────────────────────────────
📁 Folder layout (ServerScriptService)
AntiCheat/
├─ Main.server.lua
├─ Modules/
│ ├─ ScannerManager.lua
│ ├─ PhysicsValidator.lua
│ ├─ ReplicationValidator.lua
│ ├─ MemoryValidator.lua
│ ├─ NetworkValidator.lua
│ ├─ InputValidator.lua
│ ├─ IntegrityValidator.lua
│ ├─ RateLimiter.lua
│ ├─ BanManager.lua
│ └─ Util.lua
└─ Config.lua
────────────────────────────────────────
🔧 1. CONFIG (tunable constants)
-- AntiCheat/Config.lua
return {
-- Physics
MAX_WALKSPEED = 22,
MAX_JUMP_POWER = 60,
MAX_N_GRAVITY = 1.05, -- % over Workspace.Gravity
MAX_FLY_TIME = 0.35, -- seconds off ground
MAX_TELEPORT_DIST = 30, -- studs / frame
-- Replication
MAX_REPLICATE_RATE = 60, -- Hz
MAX_QUEUE_BACKLOG = 5, -- frames
-- Memory
MAX_GC_DIFF = 1024 * 1024, -- 1 MB spike
MAX_TABLE_SIZE = 5000,
-- Network
MAX_PING = 800, -- ms
MAX_PACKET_RATE = 120, -- packets/sec
-- Input
MAX_CLICK_RATE = 30, -- CPS
MAX_KEY_RATE = 60, -- KPS
-- Integrity
MAX_HASH_MISMATCH = 3, -- per session
-- Rate limiter
WINDOW = 10, -- seconds
MAX_ACTIONS = 100, -- per window
-- Penalties
KICK_THRESHOLD = 3,
BAN_THRESHOLD = 5,
}
────────────────────────────────────────
🚀 2. MAIN (bootstrap)
-- AntiCheat/Main.server.lua
local Modules = script.Parent.Modules
local Config = require(script.Parent.Config)
local scanners = {
require(Modules.ScannerManager),
require(Modules.PhysicsValidator),
require(Modules.ReplicationValidator),
require(Modules.MemoryValidator),
require(Modules.NetworkValidator),
require(Modules.InputValidator),
require(Modules.IntegrityValidator),
}
for _, scanner in ipairs(scanners) do
scanner:Init(Config)
end
────────────────────────────────────────
🧠 3. SCANNER MANAGER (orchestrator)
-- AntiCheat/Modules/ScannerManager.lua
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local BanManager = require(script.Parent.BanManager)
local ScannerManager = {}
local registry = {}
function ScannerManager:Register(player, obj)
registry[player] = registry[player] or {}
table.insert(registry[player], obj)
end
function ScannerManager:Unregister(player)
registry[player] = nil
end
function ScannerManager:Init()
Players.PlayerAdded:Connect(function(plr)
registry[plr] = {}
end)
Players.PlayerRemoving:Connect(function(plr)
self:Unregister(plr)
end)
-- Global heartbeat
RunService.Heartbeat:Connect(function(dt)
for plr, objs in pairs(registry) do
for _, obj in ipairs(objs) do
if obj.Tick then
local ok, flag = pcall(obj.Tick, obj, dt)
if ok and flag then
BanManager:Flag(plr, flag)
end
end
end
end
end)
end
return ScannerManager
────────────────────────────────────────
🧍 4. PHYSICS VALIDATOR (fly, speed, teleport, noclip)
-- AntiCheat/Modules/PhysicsValidator.lua
local Workspace = game:GetService("Workspace")
local ScannerManager = require(script.Parent.ScannerManager)
local Util = require(script.Parent.Util)
local PhysicsValidator = {}
PhysicsValidator.__index = PhysicsValidator
function PhysicsValidator:Init(cfg)
local self = setmetatable({}, PhysicsValidator)
self.cfg = cfg
self.lastPos = {}
self.offGround = {}
return self
end
function PhysicsValidator:Tick(dt, player)
local char = player.Character
if not char or not char:FindFirstChild("HumanoidRootPart") then return end
local hrp = char.HumanoidRootPart
local hum = char:FindFirstChildOfClass("Humanoid")
-- Speed check
local vel = hrp.Velocity.Magnitude
if vel > self.cfg.MAX_WALKSPEED then
return "SpeedHack"
end
-- Fly check
local ray = Ray.new(hrp.Position, Vector3.new(0, -5, 0))
local hit = Workspace:FindPartOnRayWithIgnoreList(ray, {char})
if not hit then
self.offGround[player] = (self.offGround[player] or 0) + dt
if self.offGround[player] > self.cfg.MAX_FLY_TIME then
return "FlyHack"
end
else
self.offGround[player] = 0
end
-- Teleport check
local last = self.lastPos[player]
if last then
local dist = (hrp.Position - last).Magnitude
if dist > self.cfg.MAX_TELEPORT_DIST then
return "Teleport"
end
end
self.lastPos[player] = hrp.Position
end
-- Register with manager
local inst = PhysicsValidator:Init(require(script.Parent.Parent.Config))
ScannerManager:Register(nil, {Tick = function(_, dt)
for _, plr in ipairs(game:GetService("Players"):GetPlayers()) do
local flag = inst:Tick(dt, plr)
if flag then
require(script.Parent.BanManager):Flag(plr, flag)
end
end
end})
return PhysicsValidator
────────────────────────────────────────
📡 5. REPLICATION VALIDATOR (queue desync)
-- AntiCheat/Modules/ReplicationValidator.lua
local RunService = game:GetService("RunService")
local ScannerManager = require(script.Parent.ScannerManager)
local ReplicationValidator = {}
ReplicationValidator.__index = ReplicationValidator
function ReplicationValidator:Init(cfg)
local self = setmetatable({}, ReplicationValidator)
self.cfg = cfg
self.queue = {}
return self
end
function ReplicationValidator:Tick()
local hz = 1 / RunService.Heartbeat:Wait()
if hz > self.cfg.MAX_REPLICATE_RATE then
return "ReplicationSpam"
end
end
local inst = ReplicationValidator:Init(require(script.Parent.Parent.Config))
ScannerManager:Register(nil, {Tick = function() inst:Tick() end})
return ReplicationValidator
────────────────────────────────────────
🧮 6. MEMORY VALIDATOR (table spam, GC spikes)
-- AntiCheat/Modules/MemoryValidator.lua
local ScannerManager = require(script.Parent.ScannerManager)
local Util = require(script.Parent.Util)
local MemoryValidator = {}
MemoryValidator.__index = MemoryValidator
function MemoryValidator:Init(cfg)
local self = setmetatable({}, MemoryValidator)
self.cfg = cfg
self.lastGC = gcinfo()
return self
end
function MemoryValidator:Tick()
local now = gcinfo()
if math.abs(now - self.lastGC) > self.cfg.MAX_GC_DIFF then
return "MemoryExploit"
end
self.lastGC = now
end
local inst = MemoryValidator:Init(require(script.Parent.Parent.Config))
ScannerManager:Register(nil, {Tick = function()