Anti speed hack / teleport script

Hi, I want to make a script that kicks player if they’ve moved for over than 16 steps (because player’s walk speed is 16). I tried to make some scripts like this, but it’s not working correctly:

game.Players.PlayerAdded:Connect(function(Player)
	while wait() do
		if game:GetService("ReplicatedStorage"):WaitForChild("Previous").Value >= game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z + 17 then
			Player:Kick("Exploiting!")
		else
			game:GetService("ReplicatedStorage"):WaitForChild("Previous").Value = game:GetService("ReplicatedStorage"):WaitForChild("Previous").Value >= game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z
		end
	end
end)

Help!

I am not sure about the script, but system like that kind of wouldn’t work. If player’s ping is high it will just kick him even if he is not exploiting. Making the distance higher could work, for example 50 studs, cause even with lag you wouldn’t be able to travel that far.

Anticheats aren’t about stopping cheaters but about nerfing them, you should create loop that compares player positions each 1 seconds to don’t stress the server that much, you should add maximum distance travelled by player + offset here, and if the distance is incorrect, teleport player back to last position, this way you can prevent most speed cheats in your game

2 Likes

Can i ask you to answer my last topic

I answered it, sorry if i wasn’t clear, i gave you steps to create working Anti speed / anti teleport script

Cleaner version:

while true do
    if PositionDifference > 80 then -- 80 is pretty much safest for ping
        -- Teleport player back
    end
    PreviousPosition = CurrentPosition
    task.wait(1) -- when cooldown is 1 it's harder to bypass anticheat
end

No i meant my question about this script but i got my answer

--[[
-----what i want to know is will any args i put in the args table works depending on its function ? for string things it works but
  i want to know if something like this works too , if it does not work plesse tell me and correct this part because i usually want to work with args which are not
  strings
  and also , any better ways to use args without this args table ?-----
  _G.settings={
  Methods={
    functions={[1988]=function(...) game.Players.LocalPlayer.Character.PrimaryPart.Position=Vector3.new(...) end},
    args={[1988]={1,2,3}}
  }
}
local value='1988'
for i,v in next,settings.Methods.functions or {} do
  if value==tostring(i) then
    xpcall(function()
    v(table.unpack(settings.Methods.args[i]))
    end,
    function(err) warn('Error : '..err) end)
  end
end
  ]]
_G.settings={
  Methods={
    functions={[1988]=function(...)file=io.open('/storage/emulated/0/docs/lua.txt','w');file:write(...);file:close();file=io.open('/storage/emulated/0/docs/lua.txt','r');print(file.read(file,'*all'));file:close()end},
    args={[1988]={'this is an example arg'}}
  }
}
local value='1988'
for i,v in next,settings.Methods.functions or {} do
  if value==tostring(i) then
    xpcall(function()
    v(table.unpack(settings.Methods.args[i]))
    end,
    function(err) warn('Error : '..err) end)
  end
end

I just wrote this script that is working very fine and 100%:

local StandartSpeed = 24

game.Players.PlayerAdded:Connect(function(Player)
	local ZDifference = Instance.new("IntValue")
	ZDifference.Name = "ZDifference"
	
	while wait(1) do
		if game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z >= -1 then
			if ZDifference.Value >= (game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z + -game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z * 2) + StandartSpeed then
				Player:Kick("Exploiting! Previous position: "..ZDifference.Value..". New position: "..game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z + -game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z * tonumber(2)..".")
			else
				ZDifference.Value = game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z + -game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z * 2
			end
		else
			if game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z <= 1 then
				if ZDifference.Value >= game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z + StandartSpeed then
					Player:Kick("Exploiting (Z position)! Previous position: "..ZDifference.Value..". New position: "..game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z..".")
				else
					ZDifference.Value = game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.Z
				end
			end
		end
	end
end)

game.Players.PlayerAdded:Connect(function(Player)
	local XDifference = Instance.new("IntValue")
	XDifference.Name = "XDifference"
	
	while wait(1) do
		if game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X >= -1 then
			if XDifference.Value >= (game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X + -game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X * 2) + StandartSpeed then
				Player:Kick("Exploiting (X position)! Previous position: "..XDifference.Value..". New position: "..game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X + -game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X * tonumber(2)..".")
			else
				XDifference.Value = game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X + -game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X * 2
			end
		else
			if game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X <= 1 then
				if XDifference.Value >= game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X + StandartSpeed then
					Player:Kick("Exploiting! Previous position: "..XDifference.Value..". New position: "..game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X..".")
				else
					XDifference.Value = game:GetService("Workspace"):WaitForChild(Player.Name):WaitForChild("HumanoidRootPart").CFrame.Position.X
				end
			end
		end
	end
end)

Every second player moves for like 16-18 steps, so if you’ll set standart number to 24 it will be fine. If they’ll teleport their HumanoidRootPart, it will detect that the X or Z position (WASD) is changed for over than 24 steps and will kick or ban them.
Because Roblox won’t kick the player if the X or Z value is over 0 (greater than -0.01 value), we can set the Difference to CFrame + CFrame (but - value (-CFrame)) * 2 (it will make the great number to exact the same number, but it will turn into the bad (-) one) and it will work fine.
Math always helps lol.

Do Not Ban . It is not 100% that the player is an exploiter, sometimes it might be an issue of parts / other things , kick is enough unless you are 100% sure that nothing in your game can accidentally makes them take 24 steps+

Why I can’t just put this script to ServerScriptService and it will make it disabled for a second while it’s teleporting me to other stuff?

Like, if I have a teleport part in the game, it will disable the anti cheat script for a second and will turn it on again after teleporting to the part

It will be the best solution, + if the part is located too high it won’t ban you because it’s not counting player’s Y position

  • exploiters can’t bypass it, because exploiters don’t have any access to ServerScriptService

One thing, you should use task.wait() instead of wait, as it’s faster and newer

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.