FPS Unlocker buffing my RenderStepped function, when its only meant to be for 60 FPS cap!

I understand that when you use RenderStepped, you should expect that there may be players who capped their FPS above 60, since apparently you’re allowed to do that using a third-party, and I’m just now worrying about it the moment I came across this issue, haha.

Sometimes, I would want to fire an event for every time I reach a maximum value using RenderStepped for some reason, and then reset it back to 0 so that the loop continues with that specific time loop. Over here I made it extremely simple but prints instead of firing events:

local did = 0

game:GetService("RunService").RenderStepped(function(delta)
if did >= 10 then
    did = 0
    print("help")
else
    did = did+1
end
end)

So yes again this is a very simple script, however when using FPS Unlocker to cap it above 60 FPS, the loop begins to print way faster than intended.
Like for example, when this method is being used as to regenerate health, the player with greater FPS than 60 can regenerate all their health under a second, which isn’t all that fun since they have way too much advantage.
Now yes I did use task.wait(1/60) or something like this, while its not instant this time, its still slightly faster than 60 FPS, therefore its just not accurate enough.

I would really like to know, how would you do this? How can I change this script so that no matter how much FPS you have, it will always print on that exact same time. I think delta / tick() will most likely have relevance here, although I’m just now trying getting around it while still confused on how to implement this correctly.
Looking forward for a better alternative to this method to prevent this spam, whether it can be easy and simple to learn, or advanced, or some other source that is very similar to this issue!

1 Like

Use the deltaTime parameter that gets passed to RenderStepped (and other similar events) to make your code timestep- independent. There’s lots of info online on how to do that.

You can’t rely on RenderStepped being fired at 60 Hz, even if FPS unlockers weren’t a thing. Some people’s computers won’t be able to run your game at 60 FPS all of the time, making it fire at less than 60 Hz.

1 Like

What if you get the client FPS (there is a method for It) and then do something like this:

if did >= 10*(FPS/60) then