Axolotleless

FPS capper

Jan 31st, 2025
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.38 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2.  
  3. local TARGET_FRAME_RATE = 30
  4.  
  5. local frameStart = os.clock()
  6.  
  7. RunService.PreSimulation:Connect(function()
  8.     while os.clock() - frameStart < 1 / TARGET_FRAME_RATE do
  9.         -- We do nothing until the target time has elapsed
  10.     end
  11.  
  12.     -- Mark the start of the next frame right before this one is rendered
  13.     frameStart = os.clock()
  14. end)
Add Comment
Please, Sign In to add comment