Often people ask how to prevent lag or minimize it, but for my project I want to create lag in a controlled way. I want this to be an event for a mysterious game called “The Void” where the game lags out (for the client) and then stuff visually changes after the lag subsides. How could I do this without crashing the client?
I’m not exactly sure what type of lag you’re looking for, but you can create an artificial FPS cap with something like this:
local runService = game:GetService('RunService')
local maxFPS = 1
while true do
local t = tick()
runService.RenderStepped:Wait()
repeat until (t + 1/maxFPS) <= tick()
end
I wouldn’t go lower than 1 though.
Source:
Alternatively, you could simply freeze the game until a certain time:
function freeze(time:number)
local t = os.time() + time
repeat until os.time() >= t
end
freeze(5)