I’m trying to make a server-sided anticheat that checks if the player’s speed goes above the maximum speed allowed. This doesn’t work for some reason, anyone able to help?
local maximumSpeed = 16
local checkInterval = 1
local function checkSpeed(character, player)
if character.Humanoid.WalkSpeed > maximumSpeed then
player:Kick("Speed hacks detected.")
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
while wait(checkInterval) do
checkSpeed(char, plr)
end
end)
end)
Properties changed by local scripts aren’t replicated to the server, so even if the exploiter has a walkspeed of 100 on their client, the server still sees it as 16 walkspeed. What you could do is check the current position and a stored position from the last check and see if the magnitude of the difference is too big
Just like @heII_ish said. It doesn’t replicate to the server causing the server script not being able to detect it. Even though its only changed on the client you still move faster because movement of the character is handled by the client https://gyazo.com/072e5dbb65e7746c5bb19a0c4e0f466e
Use HumanoidRootPart.Velocity.Magnitude instead. It measures how many studs the player is moving at, which are the same as the walkspeed. However, it also changes when the player is being moved in any way (fling, bodyvelocity, etc…), so you will have to make sure not to false-ban someone for something unrelated to WalkSpeed.