How can i fix this? ( FPS Tracker )

No everything is good! tysm!!!

That’s good! I recommend putting one of the psots that have helped you the most as the solution so people seeing this post can easily know which helped you the most so it can help them as well! If you have anymore issues don’t be afraid to make another post!

2 Likes

in studio i have 300 but in real game it freeze in 61 fps

There is no need to use run service functions to find the player FPS, you can simply do

local fps = workspace:GetRealPhysicsFPS()
print(fps)
1 Like

I did a bit of research and I think this may work

local rs = game:GetService("RunService")

while true do
	script.Parent.Text = 1 / rs.Heartbeat:Wait()
	wait(1)
end

I’m not sure about accuracy, but I did find that you could use 1 / step to get the fps instead of using RunService, which caps at 60 times a second

That can work but Heartbeat and RenderStepped can be very inaccurate and can cause up to ± 10 to 15 fps differences. Theres a very good tracker which I linked below

(not my code)

local Heartbeat = game:GetService("RunService").Heartbeat

local LastIteration, Start
local FrameUpdateTable = { }

local function HeartbeatUpdate()
	LastIteration = tick()
	for Index = #FrameUpdateTable, 1, -1 do
		FrameUpdateTable[Index + 1] = (FrameUpdateTable[Index] >= LastIteration - 1) and FrameUpdateTable[Index] or nil
	end
	
	FrameUpdateTable[1] = LastIteration
	local CurrentFPS = (tick() - Start >= 1 and #FrameUpdateTable) or (#FrameUpdateTable / (tick() - Start))
	CurrentFPS = math.floor(CurrentFPS)
end

Start = tick()
Heartbeat:Connect(HeartbeatUpdate)

(this needs to be a local script, and the current fps is the CurrentFPS variable)

1 Like

That’s actually the same post where I got 1 / step from actually haha. I wasn’t sure which one to post since I wasn’t sure if he was wanting speed or accuracy.

Also it can’t be a local script for what he wants since he wants the current fps of the player to be displayed for everyone, unless he decides that it’s better to use a Local Script in which case to use a Remote Event

Ohhh, well then in that case you might need to send the FPS through a remote event so the server can display it, but dang that’s a lot of firing if you’re doing it >= 60 times a second.

But I think 1 / RenderStepped:Wait() is good, but the method I linked above seems to be better for accuracy

It would probably be very unperformant to do it like that since it’s going to be fired every second, and combine that with a lot of players, and it’s going to cause performance drops most likely

I still personally think that 1 / step would be better since it’s faster although sacrifices accurate FPS, but the method you mentioned is also good for accuracy at the sake of speed

In the end, it’s going to depend on what @sk2lly wants for his game, accurate fps or fast fps display

yeah true, but then how would it update for everyone else?

Actually now that I closely realise this, I think he has no real choice but to update it with a RemoteEvent since doing it on the server would get the server’s wait time, not the client’s wait time.

The best way to do is do what you said about putting it in a local script, and what I said about RemoteEvents, but it has to update it at larger intervals, like every 5 or 10 seconds, since every second would be too much and could cause problems, especially if there are a lot of players in game

Yeah, if you have 10+ players thats 60 updates a second for each player, so 600+ updates a second for everyone, that’s a lotta work

You can’t check a client’s fps from the server. You have to use a RemoteEvent that updates every few seconds like @EmbatTheHybrid said above.

Also, the correct way to measure fps is 1 / RenderStepped:Wait() (as @Krythoptic mentioned), RenderStepped is directly connected to the framerate, whereas Heartbeat and Stepped are physics related. (they fire every frame, after and before physics calculations are finished, respectively)

RenderStepped
The RenderStepped event fires every frame, prior to the frame being rendered.

Heartbeat
The Heartbeat event fires every frame, after the physics simulation has completed.

Stepped
The Stepped event fires every frame prior to the physics simulation.


2 Likes

I think we mentioned that this is meant to be a local script, and yes although RenderStepped is the proper option, it seems that Heartbeat also runs just as well, although with Stepped, that actually comes with 2 arguments, runTime, AND deltaTime, so doing Stepped:Wait() won’t work.

local Stepped = game:GetService("RunService").Stepped

Stepped:Connect(function(runTime, deltaTime)
  local FPS = 1 / deltaTime
end)

Sorry, misread, I thought you were trying to say we weren’t doing this on a local script.

1 Like