-- AntiCheat de velocidade (Server-side)
-- Coloque este script em ServerScriptService
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
-- CONFIGURAÇÃO
local SPEED_LIMIT = 16 -- limite de velocidade horizontal (padrão Roblox
= 16)
local SAMPLE_INTERVAL = 0.12 -- em segundos (tempo entre checagens)
local MAX_VIOLATIONS = 4 -- quantas amostras acima do limite até kick
local MAX_HUMANOID_WALKSPEED = 20 -- opcional: trigger se WalkSpeed muito alto
(fallback)
local WHITELIST = { -- userIds que serão ignorados (ex.: admin)
-- [12345678] = true,
}
-- Função utilitária
local function isWhitelisted(player)
if not player or not [Link] then return false end
return WHITELIST[[Link]] == true
end
-- Decide se devemos ignorar checagem por estado do humanoid (veículo, sentado,
platformstand, etc)
local function shouldIgnoreHumanoid(humanoid)
if not humanoid then return true end
-- Ignorar se estiver sentado (seated), em PlatformStand (por exemplo,
knockback), ou morto
local state = humanoid:GetState()
if state == [Link] then return true end
if [Link] then return true end
if [Link] <= 0 then return true end
-- você pode adicionar mais condições aqui (ex.: verificar atributos
customizados)
return false
end
-- Checador por jogador
local function monitorPlayer(player)
-- armazenar contagem de violações por personagem
local violations = 0
local char = [Link]
if not char then return end
local humanoid = char:FindFirstChildOfClass("Humanoid")
local root = char:FindFirstChild("HumanoidRootPart")
while player and [Link] and char and [Link] do
humanoid = char:FindFirstChildOfClass("Humanoid")
root = char:FindFirstChild("HumanoidRootPart")
if humanoid and root and not isWhitelisted(player) then
if not shouldIgnoreHumanoid(humanoid) then
-- velocidade horizontal (ignorar componente Y)
local vel = [Link]
local horizontalSpeed = [Link](vel.X, 0, vel.Z).Magnitude
-- também verifique WalkSpeed (algumas cheats alteram o WalkSpeed)
local ws = [Link] or 16
-- Condição de detecção
local speedExceeded = horizontalSpeed > SPEED_LIMIT + 0.5 -- margem
pequena
local walkSpeedExceeded = ws > MAX_HUMANOID_WALKSPEED
if speedExceeded or walkSpeedExceeded then
violations = violations + 1
else
-- diminui contagem gradualmente quando normal
violations = [Link](0, violations - 1)
end
-- se ultrapassar limite de violações, kick
if violations >= MAX_VIOLATIONS then
local reason
if walkSpeedExceeded then
reason = [Link]("Kick: WalkSpeed detectado alto
(%.2f > %d).", ws, MAX_HUMANOID_WALKSPEED)
else
reason = [Link]("Kick: Velocidade anormal detectada
(%.2f > %.2f).", horizontalSpeed, SPEED_LIMIT)
end
-- log no servidor (Output) — você pode trocar por DataStore or
ServerLog
print([Link]("[AntiCheat] Player %s (UserId=%d) kickado.
%s", [Link], [Link], reason))
-- opcional: enviar aviso antes de kick (comentar se não
quiser)
-- player:Kick(reason)
-- Para evitar possíveis problemas de execução se o Player
tiver sumido:
if player and [Link] then
player:Kick(reason)
end
break -- termina o monitor
end
else
-- se ignorado, resetar violações
violations = 0
end
else
-- sem humanoid/root — reset contagem
violations = 0
end
-- esperar próximo sample; se o player morrer/trocar char, o loop
continuará e adaptará
wait(SAMPLE_INTERVAL)
-- atualizar referências caso a Character tenha sido trocada
char = [Link]
if not char then
-- espera até novo character aparecer
repeat wait() until [Link] or not [Link]
char = [Link]
end
end
end
-- Conecta novos jogadores
[Link]:Connect(function(player)
-- inicia monitor quando personagem aparecer
[Link]:Connect(function()
-- roda em thread separada
spawn(function()
monitorPlayer(player)
end)
end)
-- se o personagem já existir no momento de join:
if [Link] then
spawn(function()
monitorPlayer(player)
end)
end
end)
-- Monitora players já presentes (útil em play solo/test)
for _, p in ipairs(Players:GetPlayers()) do
-- iniciar para cada um
if [Link] then
spawn(function() monitorPlayer(p) end)
else
[Link]:Connect(function() spawn(function() monitorPlayer(p) end)
end)
end
end