-- a better alternative implementation for the wait function

function wait_time(duration)
    local start = tick()
    local Heartbeat = game:GetService("RunService").Heartbeat
    repeat Heartbeat:Wait() until (tick() - start) >= duration
    return (tick() - start)
end
