Advertisement
Remusutules

FPS Counter

Sep 17th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | Source Code | 0 0
  1. local fpsCounter = script.Parent
  2.  
  3. local lastTime = tick()
  4. local frameCount = 0
  5.  
  6. game:GetService("RunService").RenderStepped:Connect(function()
  7. frameCount = frameCount + 1
  8. local currentTime = tick()
  9.  
  10. if currentTime - lastTime >= 1 then
  11. local fps = frameCount / (currentTime - lastTime)
  12. lastTime = currentTime
  13. frameCount = 0
  14.  
  15. fpsCounter.Text = fps
  16.  
  17. if fps < 30 then
  18. fpsCounter.TextColor3 = Color3.new(1, 0, 0)
  19. elseif fps < 60 then
  20. fpsCounter.TextColor3 = Color3.new(0, 1, 0)
  21. else
  22. fpsCounter.TextColor3 = Color3.new(0, 1, 0)
  23. end
  24. end
  25. end)
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement