I have solved this myself.
So i have some code that in theory should kick someone with a speed over 16 (maxWalkSpeed is a value from a module script), but it only kicks them with a speed around over 1000, does anyone know why this happens?
local requireed = require(script.Parent)
local maxWalkSpeed = requireed.maxWalkSpeed
game.Players.PlayerAdded:Connect:Function(plr)
plr.CharacterAdded:Connect(function(char)
local HPR = char.HumanoidRootPart
local KickText = "kicked"
while true do wait(.2)
local pos1 = HPR.Position
wait(1)
local pos2 = HPR.Position
if pos1.X - pos2.X > maxWalkSpeed * maxWalkSpeed then
plr:Kick(KickText)
end
if pos1.Z - pos2.Z > maxWalkSpeed * maxWalkSpeed then
plr:Kick(KickText)
end
end)
end)
Something to note is that IT DOES somewhat work, just only with very high values, and I use maxWalkSpeed * maxWalkSpeed because before then it just kicked the player with any speed AND maxWalkSpeed is 16.

5 comments
You are only checking the z or x delta between the positions, you should do magnitude which checks each axis
So that would be
if (pos1- pos2).Magnitude > maxWalkSpeed * maxWalkSpeed thenThe reason is X -X can be negative which alread would fail ur condition, and Magnitude is the distance between two positions so it cant be negative
Also maxWalkSpeed^2 is quite a bit excessive to prevent false positives if you want to make sure you dont get false positives you should do maxWalkSpeed*2, or even lower if its reliable
WalkSpeed is after all studs per seconds