Advertisement
Zynee

fps display

Jan 19th, 2025
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.03 KB | Source Code | 0 0
  1. local ScreenGui = Instance.new("ScreenGui")
  2. ScreenGui.Parent = game.CoreGui
  3.  
  4. local FPSTextLabel = Instance.new("TextLabel")
  5. FPSTextLabel.Size = UDim2.new(0, 200, 0, 30)
  6. FPSTextLabel.Position = UDim2.new(0, 10, 0, 10)
  7. FPSTextLabel.BackgroundTransparency = 1
  8. FPSTextLabel.TextColor3 = Color3.fromRGB(144, 238, 144)
  9. FPSTextLabel.TextScaled = true
  10. FPSTextLabel.Font = Enum.Font.PatrickHand
  11. FPSTextLabel.Parent = ScreenGui
  12.  
  13. local UIS = game:GetService("UserInputService")
  14. local dragging
  15. local dragInput
  16. local dragStart
  17. local startPos
  18.  
  19. local function update(input)
  20.     local delta = input.Position - dragStart
  21.     FPSTextLabel.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  22. end
  23.  
  24. FPSTextLabel.InputBegan:Connect(function(input)
  25.     if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  26.         dragging = true
  27.         dragStart = input.Position
  28.         startPos = FPSTextLabel.Position
  29.  
  30.         input.Changed:Connect(function()
  31.             if input.UserInputState == Enum.UserInputState.End then
  32.                 dragging = false
  33.             end
  34.         end)
  35.     end
  36. end)
  37.  
  38. FPSTextLabel.InputChanged:Connect(function(input)
  39.     if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  40.         dragInput = input
  41.     end
  42. end)
  43.  
  44. UIS.InputChanged:Connect(function(input)
  45.     if input == dragInput and dragging then
  46.         update(input)
  47.     end
  48. end)
  49.  
  50. local function updateFPS()
  51.     local lastTime = tick()
  52.     local frameCount = 0
  53.    
  54.     game:GetService("RunService").RenderStepped:Connect(function()
  55.         frameCount = frameCount + 1
  56.         local currentTime = tick()
  57.         if currentTime - lastTime >= 1 then
  58.             local fps = frameCount / (currentTime - lastTime)
  59.             FPSTextLabel.Text = string.format("fps:%.2f", fps)
  60.             frameCount = 0
  61.             lastTime = currentTime
  62.         end
  63.     end)
  64. end
  65.  
  66. updateFPS()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement