How can I make RenderStepped lock to a maximum of 60 FPS?

It’s come to my attention that a player of my game uses an FPS unlocker which allows their game to run past 60 frames per second.

This is an issue with my game’s camera system which listens for input every frame to allow for holding down the buttons, as seen in the example below.

This is what the camera SHOULD be like at 60 FPS maximum.

This is the camera of the other user who has the FPS unlocker (not a sped-up video):

The idea would be to find a solution where all computers will run on at most equal speeds even if they use something to un-limit their FPS.

It would be very much preferred if I didn’t have to use while wait() do.

(Here is a post about that, please, search before posting)
Nevermind, it isn’t a duplicated post, however, that could help you with your issue. :slight_smile:

It might not use the best practices, but that might be a solution temporarily? Thanks for reading.

Like I mentioned, I don’t want to use wait(). It’s a terrible practice and it also sacrifices the smoothness.

Can’t really be having temporary solutions at the moment.

You could do this:

local waitTime = 1/60

while true do
   print("I'm running!")
   wait(waitTime)
end

This code will print and run 60 times per second, independant of the framerate.

You can swap the wait() call with RunService.RenderStepped:Wait().

You have got to know that humans can only see 30 FPS so it’s basically useless to go for 60

1 Like

No it won’t, wait will at least wait 1/30, nothing less. And OP clearly doesn’t want to use wait so respect that and stop providing that as a solution :slight_smile:

My bad, i thought he mean’t wait() without any arguments.

Even if you provide 1/60 as the argument, it is still going to yield for ~1/30. It won’t go any lower.

If your main concern was smoothness, you wouldn’t be looking to block players from making their game run smoother. Use the time delta argument parsed with RenderStepped and Heartbeat events and multiply your interpolations.

local p0 = 0
local p1 = 10
local speed = 5 --units/second
local prog = 0
game:GetService("RunService").Heartbeat:Connect(function(deltat)
	prog = prog  + speed*dt
	prog = math.clamp(prog,p0,p1)
end
7 Likes

Multiply your movement with the delta of renderstepped