How to return all other running instances of a function within a function

Say I have a function like

function A()
     wait(10)
     print(1)
end

Now say I called function A. Then I called it again. I want the second call to return all previous instances of the function so that it only prints ‘1’ one time. How would I go about doing this?

What do you mean by “all previous instances of the function”?

All current versions of the function that are still running

I really don’t understand what you are trying to achieve.

An easier solution is to give each function call its own “ID” and if it is outdated, stop execution after the wait.

local i = 0
function A()
    i += 1
    local id = i
    wait(10)
    if id ~= i then --if function A got executed a second time, in which case "i" will have changed
        return
    end
    print(1)
end

To test:

spawn(A)
spawn(A)

will only print 1 once.