Get client FPS trough a script

QUESTION

How could i get the players Frames per second trough a local script?
Any answers are appreciated.

Im not asking for the shift f5.

22 Likes

Its as simple as this

warn(workspace:GetRealPhysicsFPS()) -- this will print the current FPS of a client

You can run it through a loop to update it.

9 Likes

That gives me the clients physics fps, not the rendering fps.

6 Likes

As far as i know, That’s the only function ROBLOX provides to get something like this and normally they are both pretty close to eachother, So it shouldn’t be a problem.

Thanks for the suggestion but sadly its unrelated to the rendering fps lol. Test it ingame, click F5 and compare to the physics fps.

As you may know, roblox caps fps at 60, aand the event RunService.RenderStepped fires 60 times a second. See the connection?

You can simply compare the step value of it against 1/60 or figure out some better way to do that if you please (like storing 3 last differences between RenderStepped fires, and then calculating their average).

5 Likes

Don’t need to do this, Roblox capping frames doesn’t matter (and shouldn’t be relied upon to exist forever). You can do 1 / step to get the exact FPS from the RenderStepped, then do other stuff like averaging if necessary.

21 Likes

Thank you, it works. Im using this to develop a antisave system which monitors FPS and ping to determine if the user is attempting to save the place.

This isn’t a good way of detecting this. There will be tons of false positives, and it doesn’t necessarily freeze the exploiters computer when they try to save.

5 Likes

False positives yes but its honestly the only way there is right now sadly. And to freeze the exploit i run a simple “while true do” loop which crashes the user.

Well, all those checks are done locally meaning the exploiter can easily bypass them, Its kind of impossible to determine if someone is trying to do something like that if you’re just gonna do local checks (which is your only option)

So it’s better to ruin the user’s experience by randomly getting crashed in your game for no reason from false positives? The user experience should always be first, not trying to stop exploits with client side detection that will just simply get bypassed by exploiters. It will just ruin the user’s experience more than it stops exploits most likely.

6 Likes

Its for an airport, which has max 60 users at one time when we have a flight. Fair point though.

I have a much more complicated method, but it’s pretty accurate last I checked.

local RunService = game:GetService("RunService")
local FpsLabel = script.Parent

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

local LastIteration, Start
local FrameUpdateTable = {}

local function HeartbeatUpdate()
	LastIteration = TimeFunction()
	for Index = #FrameUpdateTable, 1, -1 do
		FrameUpdateTable[Index + 1] = FrameUpdateTable[Index] >= LastIteration - 1 and FrameUpdateTable[Index] or nil
	end

	FrameUpdateTable[1] = LastIteration
	FpsLabel.Text = tostring(math.floor(TimeFunction() - Start >= 1 and #FrameUpdateTable or #FrameUpdateTable / (TimeFunction() - Start))) .. " FPS"
end

Start = TimeFunction()
RunService.Heartbeat:Connect(HeartbeatUpdate)

For the new VM:

local RunService = game:GetService("RunService")
local FpsLabel = script.Parent
local TimeFunction = RunService:IsRunning() and time or os.clock

local LastIteration, Start
local FrameUpdateTable = {}

local function HeartbeatUpdate()
	LastIteration = TimeFunction()
	for Index = #FrameUpdateTable, 1, -1 do
		FrameUpdateTable[Index + 1] = FrameUpdateTable[Index] >= LastIteration - 1 and FrameUpdateTable[Index] or nil
	end

	FrameUpdateTable[1] = LastIteration
	FpsLabel.Text = tostring(math.floor(TimeFunction() - Start >= 1 and #FrameUpdateTable or #FrameUpdateTable / (TimeFunction() - Start))) .. " FPS"
end

Start = TimeFunction()
RunService.Heartbeat:Connect(HeartbeatUpdate)
137 Likes

I have one!

game:GetService("RunService").RenderStepped:Wait()

that’s it. you can while wait() do and use it that way and show it in a gui

3 Likes

Thank you, works perfect and updates fps way faster then the method i used before.

I don’t see any benefit to this compared to local fps = 1 / RunService.RenderStepped:wait().

1 Like

Mine is more accurate than doing just that.
image image image

8 Likes

Can you try 1 / RunService.Heartbeat:wait() as well?

1 Like

image image image

10 Likes