← Back to Portal Hub

Anti-Cheat Autoritativo no Servidor Roblox: Detecção de Speed Hack, Noclip e Física Espacial

By DopaBrain Studio Engineering Team • 2026-09-30 • Technical Guide

Em jogos multijogador no Roblox, scripts anti-cheat no cliente são inúteis contra injetores de memória modernos capazes de desativar ou manipular LocalScripts.

Para garantir partidas justas, é essencial um modelo autoritativo no servidor. Ao rastrear deslocamentos em delta-time, verificar colisões com raycasts e aplicar rubberbanding, o jogo permanece imune a trapaças.

1. Por que anti-cheats no cliente falham

Compreendendo como funcionam as explorações no cliente do Roblox:

2. Verificação de velocidade e teletransporte no servidor

Medição de deslocamento por frame sem falsos positivos causados por lag:

Serviço Anti-Cheat em Luau: Validação de Velocidade e Raycast Noclip
--!strict
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")

local AntiCheatService = {}

type PlayerRecord = {
    lastPosition: Vector3,
    lastTick: number,
    anomalyBuffer: number,
    isFalling: boolean
}

local trackedPlayers: { [Player]: PlayerRecord } = {}
local RAY_PARAMS = RaycastParams.new()
RAY_PARAMS.FilterType = RaycastFilterType.Exclude

function AntiCheatService.InitPlayer(player: Player)
    local char = player.Character or player.CharacterAdded:Wait()
    local hrp = char:WaitForChild("HumanoidRootPart") :: BasePart
    trackedPlayers[player] = {
        lastPosition = hrp.Position,
        lastTick = os.clock(),
        anomalyBuffer = 0,
        isFalling = false
    }
end

function AntiCheatService.OnHeartbeat(dt: number)
    local now = os.clock()
    for player, record in pairs(trackedPlayers) do
        local char = player.Character
        if not char then continue end
        local hrp = char:FindFirstChild("HumanoidRootPart") :: BasePart?
        local humanoid = char:FindFirstChildOfClass("Humanoid")
        if not hrp or not humanoid or humanoid.Health <= 0 then continue end
        
        local currentPos = hrp.Position
        local displacement = (currentPos - record.lastPosition).Magnitude
        local maxAllowed = (humanoid.WalkSpeed * dt * 1.35) + 0.5
        
        if displacement > maxAllowed and not record.isFalling then
            record.anomalyBuffer += (displacement - maxAllowed)
            if record.anomalyBuffer > 15 then
                hrp.CFrame = CFrame.new(record.lastPosition)
                hrp.AssemblyLinearVelocity = Vector3.zero
                record.anomalyBuffer = 0
                continue
            end
        else
            record.anomalyBuffer = math.max(0, record.anomalyBuffer - (dt * 5))
        end
        
        RAY_PARAMS.FilterDescendantsInstances = { char }
        local dir = currentPos - record.lastPosition
        if dir.Magnitude > 0.1 then
            local hit = Workspace:Raycast(record.lastPosition, dir, RAY_PARAMS)
            if hit and hit.Instance and hit.Instance.CanCollide then
                hrp.CFrame = CFrame.new(record.lastPosition)
                hrp.AssemblyLinearVelocity = Vector3.zero
                continue
            end
        end
        record.lastPosition = currentPos
        record.lastTick = now
    end
end

RunService.Heartbeat:Connect(AntiCheatService.OnHeartbeat)
Players.PlayerAdded:Connect(AntiCheatService.InitPlayer)
return AntiCheatService

3. Prevenção de noclip e invasão de paredes com raycasting

Bloqueando jogadores que atravessam paredes sólidas e cofres:

4. Compensação de latência e absorção de oscilações de ping

Segurança balanceada para jogadores com conexão instável:

5. Arquitetura de produção e telemetria

Execução de verificações contínuas sem comprometer a taxa de quadros do servidor:

Frequently Asked Questions

Por que checar velocidade no LocalScript não funciona?

O cliente tem controle sobre sua própria memória e pode burlar ou desativar o script facilmente.

Como evitar falsos positivos com knockback ou explosões?

O servidor registra a habilidade e expande temporariamente a tolerância de deslocamento do jogador.

Fazer raycasts no servidor gera lag?

Para 50 jogadores, 50 raycasts consomem menos de 0.2 ms de CPU por quadro quando otimizados.

Explore More Interactive Tests & Guides

Discover personalized cognitive assessments, stress evaluations, and game psychology tools on DopaBrain.

Go to Portal Hub