my script checks every sec in a folder if theres a value with the players name if it does then it checks more stuff and then if it exceeds a certain speed limit its supposed to set the humanoid back to the old position but sometimes it work in 1 direction and sometimes it dosnt
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local SpeedList = ServerStorage.PlayerList.AntiCheat.Speed
while true do
for i,v in pairs(Players:GetChildren()) do
local HumanoidRootPart = v.Character:WaitForChild("HumanoidRootPart",60)
if SpeedList:FindFirstChild(v.Name) then
local NewX = HumanoidRootPart.Position.X
local NewZ = HumanoidRootPart.Position.Z
local OldX = SpeedList[v.Name].LastX
local OldZ = SpeedList[v.Name].LastZ
local DifferenceX = NewX - OldX.Value
local DifferenceZ = NewZ - OldZ.Value
if DifferenceX > 40 then -- max amount is 40
HumanoidRootPart.Position = Vector3.new(OldX.Value,HumanoidRootPart.Position.Y,OldZ.Value)
end
if DifferenceZ > 40 then -- max amount is 40
HumanoidRootPart.Position = Vector3.new(OldX.Value,HumanoidRootPart.Position.Y,OldZ.Value)
end
SpeedList[v.Name]:Destroy()
else -- make a new folder with position and datstuff
local NewFolder = Instance.new("Folder")
NewFolder.Name = v.Name
NewFolder.Parent = SpeedList
local LastX = Instance.new("NumberValue")
LastX.Name = "LastX"
LastX.Value = HumanoidRootPart.Position.X
LastX.Parent = NewFolder
local LastZ = Instance.new("NumberValue")
LastZ.Name = "LastZ"
LastZ.Value = HumanoidRootPart.Position.Z
LastZ.Parent = NewFolder
end
end
wait(1)
end
thanks this made it so it works in all directions now i think i need to make it more precise somehow for example i have the limit set to 40 but if i set my humanoid walkspeed to 35 it still triggers it is there a formula to figure out how studs per second or smth like that?
Look, Iâm not that Professional, but I believe this script can be circumvented by any exploiters, itâs simple, just deleting it, Depending on where it is, it may be that the personâs âExplorerâ doesnât have this location and itâs not possible delete it there.
I believe DarkDex People would delete it if they found out.
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local SpeedList = ServerStorage.PlayerList.AntiCheat.Speed
Players.ChildAdded:Connect(function(child)
for i,v in pairs(Players:GetChildren()) do
local HumanoidRootPart = v.Character:WaitForChild("HumanoidRootPart",60)
if SpeedList:FindFirstChild(v.Name) then
local NewX = HumanoidRootPart.Position.X
local NewZ = HumanoidRootPart.Position.Z
local OldX = SpeedList[v.Name].LastX
local OldZ = SpeedList[v.Name].LastZ
local DifferenceX = math.abs(NewX - OldX.Value)
local DifferenceZ = math.abs(NewZ - OldZ.Value)
if DifferenceX > 40 then -- max amount is 40
HumanoidRootPart.Position = Vector3.new(OldX.Value,HumanoidRootPart.Position.Y,OldZ.Value)
end
if DifferenceZ > 40 then -- max amount is 40
HumanoidRootPart.Position = Vector3.new(OldX.Value,HumanoidRootPart.Position.Y,OldZ.Value)
end
SpeedList[v.Name]:Destroy()
else -- make a new folder with position and datstuff
local NewFolder = Instance.new("Folder")
NewFolder.Name = v.Name
NewFolder.Parent = SpeedList
local LastX = Instance.new("NumberValue")
LastX.Name = "LastX"
LastX.Value = HumanoidRootPart.Position.X
LastX.Parent = NewFolder
local LastZ = Instance.new("NumberValue")
LastZ.Name = "LastZ"
LastZ.Value = HumanoidRootPart.Position.Z
LastZ.Parent = NewFolder
end
end
end)
You shouldnât be doing this in an infinite loop, instead in the above script Iâve opted to use the âChildAddedâ event on the players service folder, which is fired whenever a new child is added to the folder, resulting in the connected function being executed which performs all the same code which was present before.
This is a lot more efficient and will not enact unnecessary stress upon the server.