How to make a FPS Counter

This may help a lot of smal devs! :smiley:

1 Like

Don’t use wait, use task.wait.

Wow thanks so much bro! I’ll defo use this

1 Like

just use 1/game:GetService"RunService".RenderStepped:Wait()

2 Likes

@Mimibienv

What do you mean by this?

Like where do you put it?

Thanks! usually the methods i was finding were absurd but this one is very practical. :smiley:

I saw this and thought of another way of doing it, basically the same thing but you can use an interval to get possible faster results.
WARNING
the lower the number the less accurate the results will be

local RunService = game:GetService("RunService")
local TextLabel = script.Parent -- Assuming the FPS counter is a child of a TextLabel

local frames = 0
RunService.RenderStepped:Connect(function()
	frames = frames + 1
end)
local interval = .7
while wait(interval) do
	TextLabel.Text = "FPS: " .. math.round(frames/interval)
	frames = 0
end

image
image
image
As shown, results can go above the allowed fps(60) and but will for the most part stay somewhat accurate
Make sure to keep the math,round if you are using decimals, you can get .66666, .333333, ect ruining the counter.

How about Heartbeat instead of rebderstepped

Heartbeat runs every frame after physics are calculated.

Renderstepped runs every frame before each frame is rendered.

Renderstepped Is being used so the TextLabel displays the number of frames graphically rendered, instead of the rate physics gets applied to the game.

(Also please tell me if this is wrong, I’m not 100% sure and I’m still learning.)