GetRealPhysicsFPS() > 65 = Good?

Good morning / Good evening,

I was wondering if this script can actually prevent players from teleporting :

Folder : StarterPlayerScripts

while wait(1) do
	if workspace:GetRealPhysicsFPS() > 65 then
		game.Players.LocalPlayer:Kick()
	end
end

Admitting of course that in the game, no physical element can make you exceed the maximum speed. And that the falls will be preventively stopped by hitboxes.

I’m dubious since it’s a LocalScript.

Thx for your help :slight_smile:

1 Like

Usually for checking/banning people for teleporting you can just send the clients’ position to the server at a rate of 20-30Hz and if they exceed a certain “velocity”, so to speak (distance traveled from last ping > normal travel time between two points), then you can just teleport them back to the last “good” point, essentially rubberbanding them.

1 Like

This isn’t a reliable way of stopping teleporting in your game. The documentation page states that it’s not 100% reliable.

Moving on, a reliable way of stopping exploiters from teleporting would be to do as such:

  • Get their current position. (HumanoidRootPart.Position)
  • Get their previous position. (HumanoidRootPart.Position, however you’ll have to get this from the previous frame. You can do this by using a RunService.Heartbeat connection and updating a local variable at the end of it, example below.)
  • Calculate the distance between the two points. (HumanoidRootPart.Position - PreviousPosition).Magnitude)
  • Check if this is over a certain limit. Make sure to factor in a leeway for lag or unpredictable physics on Roblox’s end. Also adding in Humanoid.WalkSpeed would help you catch walkspeed and teleport exploiters in one script.
  • If the player goes above said threshold, teleport them back to their PreviousPosition. Something like so: HumanoidRootPart.CFrame = CFrame.new(PreviousPosition). I use CFrame for unlisted reasons, you can just set .Position = PreviousPosition.
1 Like

I agree with @BullfrogBait but want to add that you should not kick on the client

1 Like

Ok that means I’m going to have to place this in the Server as well as add several functions and also replace this with a GetService(“Player”), calculate the distance, check the player’s CFrames and this Position and then connect everything. Should I also indicate the Vector3 ?

Given that several tasks will be carried out, what should I use ?

You can use (Vector3.new(1, 0, 1) * CurrentPosition) - Vector3.new(1, 0, 1) * PreviousPosition)).Magntiude and that should get the distance between two points on the X and Z axes.

I don’t think you’ll need to use CFrame until you set the player back to their original position. Even then it might not be used, I only added it because I had physics problems when setting Position over CFrame but that was because of another part of my script that I chose not to write about.

I’m not entirely sure what you’re asking, but I would use a Heartbeat connection and loop through all players. Or better yet you can look into Parallel Lua and have one Heartbeat per player, however if none of that made sense just ignore it for now.

Something like this:

local PreviousPosition = HumanoidRootPart.Position

RunService.Heartbeat:Connect(function(DeltaTime) --DeltaTime is the time between events. You will want to use this incase of lag(?)
    local CurrentPosition = HumanoidRootPart.Position
    -- do all stuff here. check for tping/speed hax with math, etc
    if IsntSuspicious then
        PreviousPosition = HumanoidRootPart.Position
    end
end)