I have made a FPS limiter script, and it's working just fine. But if the user changes the FPS limit to something else, they would need to rejoin the game for the changes to take effect, because the script wouldn't register the changes.
I have tried disabling and enabling again and cloning but none worked. Can someone help me out?
Script: (without the resetting code)
local FPSCAP = game.StarterGui.ScreenGui.System.FPS.LimitFPSto.Value local LOOPCount = 200 local MLoopCount = 27 local FPS = 0 local Broken = 0 local function DOLOOP() spawn(function() while true do game:GetService("RunService").Heartbeat:Wait() if FPS+5 < FPSCAP and Broken <= LOOPCount*MLoopCount then Broken += 1 break end end end) end game:GetService("RunService").RenderStepped:Connect(function(delta) FPS = 1/delta end) spawn(function() while true do game:GetService("RunService").Heartbeat:Wait() if FPS >= FPSCAP then spawn(function() for i = 1, LOOPCount do DOLOOP() end end) end end end) spawn(function() while wait(1) do Broken = 0 end end)
This might be a bad take because I'm still fairly new to programming, but try using > BindableEvents with two scripts, one that fires an event when a change is made, and one script that actually handles the changes. This should remove the restart script thing entirely and it will make the code more efficient as well. Hope this helps:)
I’m gonna need to see your script to help ya here.