You can probably fix the speed issue by dividing it by the time passed using os.clock()
I don’t want to be kicked just because I used an FPS unlocker, and maybe Roblox will use VSync in future instead of a 60 FPS cap, making this code kick everyone who has a monitor with a higher refresh rate.
After a bit of research i found this script
local RunService = game:GetService("RunService")
local MaxFPS = 30
while true do
local t0 = tick()
RunService.RenderSteppedt:Wait()
repeat until (t0 + 1/MaxFPS) < tick()
end
i didnt make it but it works just fine.
edit : just realized this was posted here before.
My god this is horrible, the script activity is over 70% sometimes.
Sorry I’m late:
Could you explain this? I don’t understand what tick() does, or why we set clock to tick() again?
Returns how much time has elapsed, in seconds, since the UNIX epoch, on the current local session’s computer. The UNIX epoch is represented by the date January 1st, 1970.
for anyone looking for a better solution, this caps it at exactly the cap you put, even if they are using an fps unlocker or anything else it will still work
local fpsCap = 165
local clock = tick()
game:GetService("RunService").RenderStepped:Connect(function()
while clock + 1 / fpsCap > tick() do end
clock = tick()
task.wait()
end)