How to use a wait() that doesnt yield longer due to laggy game

Hello everyone and I am making a sit up minigame in my game. Everything is working great and the only problem I’m having is that if someone has even a medium ping, it becomes impossible. In my minigame u have to press a button within 0.2 of it being their, meaning if your ping is 200 the whole game is doomed. This is because I use wait() and I know that lag effects it. Is their another method of yielding a specific code in like, lets say a function, and continuing with the time specified (similar to wait) but with no lag deficiency?

You could use a Custom Wait instead of Roblox’s default wait.

I recommed this one for your usage

And to use it is simple, copy the code that the source code gives you, and paste it into a modulescript. Then to use it, jsut create a variable that requires the module and run it whenever


local Wait = require(game.ReplicatedStorage.CustomWait)



It’s much more efficient than using Roblox’s built in wait


You could use RunService to implement a custom wait function:

local rs = game:GetService("RunService")
function rsWait(t)
	local c = 0
	local dt
		_, dt = rs.Stepped:Wait()
		c = c + dt
	until (c >= t)
	return c
1 Like

i dont know which one to pick but thank you guys! ill just mark the first responce

actually i think i should kinda test the first

Stepped’s first return is how many steps have passed, not the delta from the last tick, that’s the second return.

1 Like

Forgot about that. I edited my post to fix it.