I’m mainly asking if something like this would end up slowing down my game and if there’s a more efficient way of keeping track time.
local heartbeat = game:GetService("RunService").Heartbeat
local duration = 5
local timeStarted = tick()
connection = heartbeat:Connect(function()
if tick() - timeStarted > duration then
-- run function here
Also keep in mind duration is able to be changed from any other script.
All input is appreciated so please do share if you have something to say thanks.
So you want to wait until 5 seconds have passed and then run a function? That shouldn’t cause too much lag, unless you had many of these functions. Unless it needed to be extremely precise, couldn’t you just do a while wait(1) loop?