Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Whats the math for 16 walkspeed according to position?

Asked by 5 years ago

So Im trying to make a anti exploit and if their walkspeed is just above 16 I will teleport them back to the position but I dnt know the math for 16 walkspeed I heard its studs per second

so for example since u cant see walkspeed on the server

Player walks 20 studs per second then I teleport them back

0
Probably a good idea to make it higher due to people with bad internet which makes them look teleporting to the server the8bitdude11 358 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Here is a script that will print warnings when players travel faster than their WalkSpeed.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        -- wait for character to be inserted into Workspace
        character.AncestryChanged:wait()

        local lastPosition = character.HumanoidRootPart.Position

        while character.HumanoidRootPart:IsDescendantOf(game) do
            local actualTime = wait(1)
            local expectedMaxDistance =
                character.Humanoid.WalkSpeed * actualTime
            local actualDistance =
                (character.HumanoidRootPart.Position - lastPosition)
                .magnitude
            local actualSpeed =
                actualDistance / actualTime

            lastPosition = character.HumanoidRootPart.Position

            if actualSpeed > character.Humanoid.WalkSpeed then
                print(player.Name.." might be using hax! They traveled at "
                    ..actualSpeed.." studs/second, but their WalkSpeed is "
                    ..character.Humanoid.WalkSpeed..".")
            end
        end
    end)
end)

Note that this doesn't account for falling, network rubberbanding, inaccuracies in the Roblox engine regarding character speed, changes in position due to spawning, etc. Tracking a player's speed should only be one small heuristic used alongside other methods to determine if hacks are being used!

Ad

Answer this question