This may help a lot of smal devs!
Don’t use wait, use task.wait.
Wow thanks so much bro! I’ll defo use this
just use 1/game:GetService"RunService".RenderStepped:Wait()
Thanks! usually the methods i was finding were absurd but this one is very practical.
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
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.)