How To Set Max Fps Via Script?

  1. What do you want to achieve? I Want To Implement A Fps Unlocker Screen On My Games Settings Menu.

  2. What is the issue? There Isnt Any Tutorials

  3. What solutions have you tried so far? Tried Looking Into UserSettings() but there wasnt anything about fps.

welp

4 Likes

You can’t. Only maybe through busywaits, but good luck making those reliable.

1 Like

You want to create a setting in your game that would allow users to set the target FPS?

If that’s what you are trying to achieve, it’s not possible. Roblox doesn’t “officially” support unlocked fps, if you want to do so, you have to create a file inside of the Roblox appdata (or use a fps unlocker)
You could limit the fps by causing lag on the client (probably by having a loop that runs until enough time has passed, without using task.wait() because that yeilds)

Also, what is the video showing exactly? Is it an external program?

1 Like

In a lot of programs (e.g. Minecraft, and probably Roblox too) FPS is limited by calculating the difference between the target frame time and the actual frame time and then waiting. Typically this is done with a proper wait, but you can also do this with a busy wait where you keep running until the time is elapsed, although I would not recommend that because it means you’ll be constantly using CPU checking the time over and over.

It’s a lot friendlier on the user to just not limit the framerate at all, and if they want to passively limit their framerate they can just use an FPS unlocker and set it lower.

If you would still like to do this here’s what you need to do:

  • Measure the frame time that has elapsed.
  • Run a while loop that busy waits until the desired frame time has been met in one of the RunService connections. This can be done by waiting until the time since the frame began exceeds your target frame time, which is 1 / targetFrameRate.

Put together, you should get something like this:

local RunService = game:GetService("RunService")

local TARGET_FRAME_RATE = 30

local frameStart = os.clock()

RunService.PreSimulation:Connect(function()
	while os.clock() - frameStart < 1 / TARGET_FRAME_RATE do
		-- We do nothing until the target time has elapsed
	end

	-- Mark the start of the next frame right before this one is rendered
	frameStart = os.clock()
end)
2 Likes

It Was A Game That Had This Feature

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.