(Beginner) Frames per second tracker

Hi there! This is my first tutorial so please bear with me.
Thanks to @SoCalifornian, @Mystifine and @Avallachi.
In this tutorial, I will be showing you how to make a simple FPS tracker, if you’re already familiar with how to do this then I suggest moving on as this is a fairly simple thing to do.

The first thing you’ll want to do is create a ScreenGui (I assume you’re already in a place)

The Next thing you should do is name the ScreenGui “FPS” or something along those lines, just so you know where to find it.

The next thing is to create a TextButton

Once again, you should name it something like “Main” or something like that, and change the properties around to make yours unique

Next is the fun part, scripting it!
What you do first is create a local script, name it “GetFPS” or something like that, and type the code below out, I have added comments to help you out
local RunService = game:GetService("RunService")

We’re getting the RunService so we can update the gui each frame

RunService.RenderStepped:Connect(function(frame) -- This will fire every time a frame is rendered
script.Parent.Text = (math.round(1/frame).. " fps") 
end)

You can copy and paste this if you want but I suggest actually typing it out.

It’s that simple! Here’s an example video to show it working

Thanks for reading through and have a good day!

24 Likes

If you have any questions please leave them here! :slightly_smiling_face:

Could you show an example video of it in action?

1 Like

You should mention the fact that this is PhysicsFPS and not client frame rate though it may affect it.

4 Likes

Sure! I’ll work on that right away!

1 Like

I added a YT video so you can see it in action

You could also calculate the FPS using the DeltaTime argument given by RenderStepped, the change would simply be:

RunService.RenderStepped:Connect(function(deltaTime) -- This will run every time a frame is rendered
	main.Text = (math.round(1 / deltaTime) .. " FPS") -- Setting the text of the gui to the FPS and appending "FPS"
end)

This eliminates the function call (plus the second call) and is tied to the actual rendered FPS rather than tied to the Physics FPS

Explanation for beginners:
DeltaTime is simply the time between each frame. We are dividing 1 by DeltaTime because it’ll tell us how many times that number can go into one - basically how many frames we can fit in a second.

So if we are running at 60 FPS, DeltaTime will be 1/60 (1 second per 60 Frames); but, this number will be extremely small (0.0167 in fact)! So to get the actual frame count per second we simply divide 1 by that number!

13 Likes

Thanks for the suggestion! I didn’t do that simply for the reason of this being a basic beginner tutorial and I didn’t want things to get very “mathy” and physics FPS is a good start for beginners

2 Likes

Like @Mystifine mentioned this isn’t monitor frame rate (fps), but rather at what rate Roblox’s built-in physics get updated.

Thanks! I think I’ll change up the script and update the tutorial and give some credit

Nice work but the names misleading, you’re not calculating FPS…

Think this method is still more accurate. I’ve demonstrated it before.

1 Like

Yes, it may be more accurate, but remember, this tutorial is for absolute beginners, so I’m looking for simplicity

2 Likes