roblox studio fps counter
local RunService = game:GetService("RunService")
local FpsLabel = script.Parent
local TimeFunction = RunService:IsRunning() and time or os.clock
local LastIteration, Start
local FrameUpdateTable = {}
local function HeartbeatUpdate()
LastIteration = TimeFunction()
for Index = #FrameUpdateTable, 1, -1 do
FrameUpdateTable[Index + 1] = FrameUpdateTable[Index] >= LastIteration - 1 and FrameUpdateTable[Index] or nil
end
FrameUpdateTable[1] = LastIteration
FpsLabel.Text = tostring(math.floor(TimeFunction() - Start >= 1 and #FrameUpdateTable or #FrameUpdateTable / (TimeFunction() - Start))) .. " FPS"
end
Start = TimeFunction()
RunService.Heartbeat:Connect(HeartbeatUpdate)