Anti TP Exploit

In my game I wanted to do a anti teleport exploit. And I found one on the devfourm but it used positions instead of CFrames which is glitchy. I assume that you would see if the player has moved farther than normal. But how would I do this?

What’s the reason for it? I honestly don’t see much of an issue with it unless it affects your game(obby, some sort of USA type getting out of jail). What’s the game setting you need a anti tp script for?

How exactly is using position more glitchy?

I guess I don’t really need it. It is a survival game where you are out in the wilderness. But, I would be nice to have just so that exploiters can’t teleport. Especially if I add areas where the exploiter could teleport to places where you aren’t supposed to go.

It moved the humanoid root part only. I am not sure if it is true but I heard that it is best to use CFrames instead of positions because positions can cause problems like glitchy teleporting.

The simple answer is to utilize the studs per second. Calculate from their last position to their next position within X amount of time.

If that number of studs is beyond a level, it is suspicious. Do not throw them back to the original position and tick a flag up. If three flags are hit, move them back to the first flag. If that movement is unbelievable and not possible, move them back immediately.

Counter false positives when the humanoid is freefalling, knocked down and flying. It gets slightly complicated with movement speed boosting factors.

Use the Heartbeat runservice, its good for stuff like this. Ideally, you get their latest position and then check if their new position is much greater than usual

debounce = false
Check = false 
humanoidrootpart = Player.HumanoidRootPart
maxDistance = 44
RunService.Heartbeat:Connect(function()
    if humanoidrootpart then
        if Check == false and debounce == false then	
            debounce = true
            LastestPos = humanoidrootpart.Position	
            wait(.1)
            Check = true
            debounce = false
        else
            if debounce == false then	
                local NewPos = humanoidrootpart.Position	
                if (LastestPos - NewPos).Magnitude > maxDistance then
                    -- KICKKKED 
                end	
                Check = false
        end
    end
end)

This checks if the player moves (maxDistance) in about a mili-second, if a lot then the person is teleporting or speed hacking, then you punish them however.

4 Likes

The worst case scenario is when the character hits a false positive(freefalling, flung, etc.) Catch those by checking the humanoid’s current state with that velocity.

Good point. But that could be exploited though, just changing the y of your teleport so you can free fall to your destination, and the script won’t catch it because it’s letting free falling players get a pass.

Besides, I think Apocalypse Rising did it best, if you got flung, you got disconnected and when you rejoined you would spawn and fall taking no damage rather than not getting disconnected, falling, and potentially dying, which one is more fair.

Thank you for your help! It seems to work! Also @Operatik, I don’t have anywhere in the game where there is a big drop. I will do some editing if I add one. If the player is falling from a large distance it is probably from an exploit. :smiley:

Not the most viable solution as the exploiter can destroy the script that does this. You would most likely have to do this server-side.
How would you do this?

  • Create a dictionary of players with their last recorded position
  • Create a loop of your script with the “spawn” function this will sort the issue
1 Like