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?
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)