How to kick someone if their fps is under 20?

Hello. How could I kick someone if their fps is under 20? This is my code.
The prints are just for debugging.

Main:
local RS = game:GetService(“RunService”)

local punish = require(script.Parent.Parent.Punish)

local FPSKick = script.Parent.Parent.Remotes.FPSKick

local conf = require(script.Parent.Parent.Parent.init.conf)

local init = require(script.Parent.Parent.Parent.init)

local TimeFunction = RS:IsRunning() and time or os.clock

local LastIteration, Start

local FrameUpdateTable = {}

local fps

repeat wait() until conf.ready == true

print(conf.ready)

local function HeartbeatUpdate()

LastIteration = TimeFunction()

for idx = #FrameUpdateTable, 1, -1 do

FrameUpdateTable[idx + 1] = FrameUpdateTable[idx] >= LastIteration - 1 and FrameUpdateTable[idx] or nil

end

FrameUpdateTable[1] = LastIteration

fps = math.floor(TimeFunction() - Start >= 1 and #FrameUpdateTable or #FrameUpdateTable / (TimeFunction() - Start))

end

print(1)

print(fps)

Start = TimeFunction()

RS.Heartbeat:Connect(HeartbeatUpdate)

print(2)

FPSKick:FireAllClients(fps)

print(3)

Local:

local FPSKick = workspace.AntiReach.CORE.Remotes.FPSKick

local punish = require(workspace.AntiReach.CORE.Punish)

local player = game.Players.LocalPlayer

print(4)

FPSKick.OnClientEvent:Connect(function(fps)


if fps < 20 then

punish.punish(player, 'low fps!')

end

end)

https://developer.roblox.com/en-us/api-reference/function/Workspace/GetRealPhysicsFPS

I probably should have been more specific. The localscript doesn’t seem to be receiving the event.

You can try this:

---------LocalScript---------------
local plr = game.Players.LocalPlayer
local run = game:GetService(“RunService”)
local FPS = 0

run.RenderStepped:Connect(function()
FPS = FPS + 1
end)

while wait(1) do
if FPS < 20 then
plr:Kick(“Low FPS”)
end
FPS = 0
end

2 Likes

Obligatory, “why are you doing this, don’t?” for real though don’t do this, even the person with a NASA computer could get lagged for a second by windows or something, boom. kicked, super annoying

Here’s how you can do it though:

local LastMeasure = os.clock() + 5
local Fps = 0

game:GetService("RunService").Heartbeat:Connect(function()
    Fps += 1

    if os.clock() > LastMeasure then
        local _ = Fps < 20 and game:GetService("Players").LocalPlayer:Kick("e")

        Fps = 0
        LastMeasure = os.clock() + 1
    end
end)

I agree this is kinda dumb to kick someone if their fps is low, but to avoid kicking for sudden dips you can keep track of their weighted average fps. Even if the fps drops suddenly for a second the average value wouldn’t drop significantly unless their fps was consistently low.

Though that would defeat the purpose of the system in the OP.

I’m doing it for a anti-reach model I’m making. But the problem was already solved. Thanks.