I have a game where having a higher than 60 FPS gives you an unfair advantage where they move quicker in the environment (I don’t know why, it just is how it is).
To stop this I have a script that doesn’t let them do anything until they cap their framerate; turn off their FPS unlocker.
Is there anyway to just cap their frame rate using a script instead?
I saw in Super Nostalgia Zone they somehow cap frame rate at 30.
Are you sure trying to patch the >60 FPS advantage is absolutely not possible? I feel like that’d be a better solution than trying to use use an FPS cap as a bandaid.
Yes it is possible to do FPS capping, using tick() and RenderStepped. I made a 60FPS cap script, but keep in mind scripts like these can cause unnecessary lag. I personally use fps unlockers, so I just changed all my RenderStepped functions to be independent of frame rate by using DeltaTime so that I wouldnt need the FPS script anymore
In a studio test the client and server ends are running on the same machine (yours). In an online game that script would only be slowing down the server. It needs to slow down the client. So @OptimisticSide’s code should be put in a local script in StarterPlayerScripts.
The script lowered the FPS count but did not really cap it to the number listed.
Ex. I set the fps variable to 10, when I went into my place with my FPS unlocker my FPS was still around 130 FPS
When I had the variable set to 60 I was around 180 FPS
When I had the script disabled I was around 270 FPS
You aren’t supposed to cap the FPS if it gives you an advantage. You’re supposed to write code that works with all framerates.
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function(deltaTime)
-- multiply the movement amount by deltaTime.
end)
You most likely forgot to multiply the movement by deltaTime before you applied it on the player. Delta time is basically the time it took to render the last frame, and it’s useful in creating smooth animations on any framerate, and making sure things tied to renderstep happen at the same speed on all clients, no matter what their framerate is.
In the unlikely even that it’s in a roblox script, you can just clone the roblox scripts while you’re testing and then paste it into studio when you’re done testing. Then, find the code that relates to swimming and make sure they are multiplying the movement by deltaTime. If they aren’t, you can edit the script to fix it, and then file a bug report.
Capping FPS is going to make a lot of players confused/annoyed, and they’re probably going to leave the game because of it. Instead of finding a hacky solution like capping FPS, you should just fix the actual issue.
I know this conversation happened a few months ago, but I was trying to do the same thing and the script didn’t work. It capped fps, but not at the specified number. I don’t know why this is. Ex: Specified number: 10 Fps: 22
local RunService = game:GetService("RunService")
local MaxFPS = 30
while true do
local t0 = tick()
RunService.Heartbeat:Wait()
repeat until (t0 + 1/MaxFPS) < tick()
end
Note this won’t be exact (normally within 5 fps, lower fps values will be closer to the desired FPS) but is closer than what was posted. Also, unless this is for an effect (like Super Nostalgia Zone’s 30 fps cap to emulate old roblox), code should be designed to work on any framerate, so just keep that in mind
its not but i think you can kick players manually by counting the fps
local RS = game:GetService("RunService")
local FPS = 0
local player = game.Players.LocalPlayer
RS.RenderStepped:Connect(function()
FPS += 1
end)
while task.wait(1) do
if FPS > 63 then
player:Kick()
else
FPS = 0
end
end
you need to make the fps count a little bit more higher than 60 because sometimes roblox exceeds that limit
(just realized im super late😅 sorry for that)