local RunService = game:GetService("RunService")
local FPS = nil
RunService.Heartbeat:Connect(function(deltaTime)
FPS = math.floor(1/deltaTime)
end)
while wait(1) do
script.Parent.Text = FPS
end
Problem:
When FPS capped at 120 in Studio, the FPS counter shows 125 or any number that isn’t my real frame rate. However, when using different methods, the FPS indicator is accurate?
Is this due to the in accuracy of ROBLOX?
Also tried using RenderStepped to no avail, but when using Stepped, the FPS counter is accurate just 1 fps below.
Counting the amount of updates every loop is a more reliable way to get the current rendering FPS, since the difference in the deltaTime values of the Heartbeat event can be quite big.
Example:
local RunService = game:GetService("RunService")
local updates = 0
RunService.Heartbeat:Connect(function()
updates += 1
end)
while (true) do
local deltaTime = wait(1)
local FPS = math.floor((updates/deltaTime) + 0.5)
updates = 0
script.Parent.Text = FPS
end
Using tick() to calculate the time elapsed since the last frame?
local RunService = game:GetService("RunService")
local FPS = nil
RunService.Heartbeat:Connect(function(tick)
FPS = math.floor(1/tick)
end)
while wait(1) do
print(FPS)
end
Now this is a rude thing to say to someone who’s trying to help and also providing the sufficient solution. The value you get from :GetRealPhysicsFPS() equals to how many times per second the viewport including physics currently get updated, and since Roblox caps this value to ~60, then that is also what you’ll get or less if you don’t unlock this cap.
Monitor refresh rate, which I think you’re looking for, is something else. It doesn’t matter how fast your monitor is, if the game cannot keep up with it - which in this case is capped to 60 fps.
Went in studio and messed around a bit but couldn’t get an accurate counter of my FPS. So I browsed the forum to see if anyone came up with something similar and sure enough they did. Le Script. I just wrote it like this because I wanted to lol.
local FPSLabel = script.Parent
local RunService = game:GetService("RunService")
local RenderStepped = RunService.RenderStepped
local sec = nil
local FPS = {}
local function fre()
local fr = tick()
for index = #FPS,1,-1 do
FPS[index + 1] = (FPS[index] >= fr - 1) and FPS[index] or nil
end
FPS[1] = fr
local label = script.Parent
local fps = (tick() - sec >= 1 and #FPS) or (#FPS / (tick() - sec))
fps = math.floor(fps)
label.Text = ""..fps.." FPS"
end
sec = tick()
RenderStepped:Connect(fre)