Hello! Before you say, “this post has been made a million times,” I know. I have read over ten dev forum posts on this, and nothing seems to fit my liking.
What do I want to achieve?
I want to make a anti-teleport system that does the following:
- Allows the player to fall
- Make it so the exploiter cannot put themselves in a falling state to bypass tp
- Allows in-game teleports to still function
- Does not affect high ping players
What have I tried so far?
I have looked at a lot of posts, and they all use magnitude, so I thought I would do this too. Here is my code:
game.Players.PlayerAdded:Connect(function(Player) debounce = false Check = false humanoidrootpart = Player.HumanoidRootPart maxDistance = 50 --I will mess around with this when the script works how it should. game:GetService("RunService").Heartbeat:Connect(function() if humanoidrootpart then if Check == false and debounce == false then debounce = true LastPos = humanoidrootpart.Position wait(.1) Check = true debounce = false else if debounce == false then local NewPos = humanoidrootpart.Position if (LastPos - NewPos).Magnitude > maxDistance then Player:Kick("Teleported.") end Check = false end end end) end)
This code doesn’t help with high ping players, and doesn’t prevent a player from getting kicked if they are falling.
What other posts have I looked at?
The best post I have found is this: Anti TP Exploit - #6 by Operatik
That post covers anti exploits, but can still affect players falling, and laggy players.
Another thing is, I would need to make a second thing like this that tracks the players total distance over a total of ten seconds. The reason for this is that the player could easily make themselves teleport a bit at a time over and over again. This would totally counter this system.
The tricky thing is exploiters can do so much, and you are never safe. The best we can do is prevent a couple big things like teleporting. If you can help, please leave a reply. I am not asking for an entire script, just how I would do the things I want to achieve.
(This is my first post ever, how do you think I did?)