Advertisement
choco99

get fps and ping in roblox

Jan 7th, 2023
1,994
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2.     local FpsLabel = script.Parent
  3.  
  4.     local TimeFunction = RunService:IsRunning() and time or os.clock
  5.  
  6.     local LastIteration, Start
  7.     local FrameUpdateTable = {}
  8.  
  9.     local function HeartbeatUpdate()
  10.         LastIteration = TimeFunction()
  11.         for Index = #FrameUpdateTable, 1, -1 do
  12.             FrameUpdateTable[Index + 1] = FrameUpdateTable[Index] >= LastIteration - 1 and FrameUpdateTable[Index] or nil
  13.         end
  14.  
  15.         FrameUpdateTable[1] = LastIteration
  16.     local fps = tostring(math.floor(TimeFunction() - Start >= 1 and #FrameUpdateTable or #FrameUpdateTable / (TimeFunction() - Start)))
  17.     script.Parent.Text = "FPS = "..fps.."    Ping = "..game:GetService("Stats").Network.ServerStatsItem["Data Ping"]:GetValue()
  18.     end
  19.  
  20.     Start = TimeFunction()
  21.     RunService.Heartbeat:Connect(HeartbeatUpdate)
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement