Hi there! I'm curious on how to get the distance a player walked, the one I have right now is pretty bad since it doesn't get how many studs a player walked so its almost exactly the walkspeed of the player. Can anyone help?
if checkState(player, "antiTeleport", humanoid:GetState()) then --Just to check if the player is NOT jumping/falling
local humanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
local playerPosition = humanoidRootPart.Position
wait()
local currentPosition = humanoidRootPart.Position
print((currentPosition - playerPosition).magnitude) --Just for debug
if (currentPosition - playerPosition).magnitude > 15 then
wait(1/10)
if not isBanned(player) then
dataStore:SetAsync(key, {true, 168, os.time()}) --Just to ban
player:Kick(reason)
print(player.Name .. " has been banned!")
return
end
end
end

4 comments
Just so you know, the default walkspeed is 16. Your code (line 9) kicks a player for walking at the default speed.
Be careful with code like this. Your code does not account for server throttling. The
waitfunction does not always wait the amount of time you give it. If your game has a lot of players all doing things and walking around, it's possible that it will be significantly longer (up to 10 seconds or even more until your script resumes from the yield). If that were to happen, you'd have kicked any...players who moved during the time that your server throttled.
waitreturns a number, which is the actual amount of time waited. You should consider this as a factor in your process of determining if the player teleported.something like timeWaited = wait()?