Advertisement
ERROR_CODE

.FPS

May 12th, 2023 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1.     local FPSLabel = script.Parent
  2.     local RunService = game:GetService("RunService")
  3.     local RenderStepped = RunService.RenderStepped
  4.     local sec = nil
  5.     local FPS = {}
  6.  
  7.         local textlab = Instance.new("TextLabel")
  8.     textlab.Size = UDim2.new(0, 200, 0, 28)
  9.     textlab.BackgroundTransparency = 1
  10.     textlab.TextColor3 = Color3.new(1, 1, 1)
  11.     textlab.TextStrokeTransparency = 0
  12.     textlab.TextStrokeColor3 = Color3.new(0.24, 0.24, 0.24)
  13.     textlab.Font = Enum.Font.SourceSans
  14.     textlab.TextSize = 30
  15.     textlab.Text = ""
  16.     textlab.BackgroundColor3 = Color3.new(0, 0, 0)
  17.     textlab.Position = UDim2.new(0, 0.1, 0.9, 0.1)
  18.     textlab.TextXAlignment = Enum.TextXAlignment.Right
  19.     textlab.BorderSizePixel = 0
  20.     textlab.Parent = game.CoreGui.RobloxGui
  21.     textlab.Visible = true
  22.  
  23.     local function fre()
  24.     local fr = tick()
  25.     for index = #FPS,1,-1 do
  26.     FPS[index + 1] = (FPS[index] >= fr - 1) and FPS[index] or nil
  27.     end
  28.     FPS[1] = fr
  29.     local fps = (tick() - sec >= 1 and #FPS) or (#FPS / (tick() - sec))
  30.     fps = math.floor(fps)
  31.     textlab.Text = ""..fps.."  -  FPS"
  32.  
  33.     if fps < 30 then
  34.     textlab.TextColor3 = Color3.new(0, 0, 0)
  35.     elseif fps < 45 then
  36.     textlab.TextColor3 = Color3.new(100, 0, 0)
  37.     elseif fps < 60 then
  38.     textlab.TextColor3 = Color3.new(100, 100, 0)
  39.     else
  40.     textlab.TextColor3 = Color3.new(0, 100, 0)
  41.     end
  42.     end
  43.    
  44.     sec = tick()
  45.     RenderStepped:Connect(fre)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement