Will a event listener be active even when a function has returned a value

For example

function myFunc()
    Players.PlayerAdded:Connect(function(plr)
        print(plr)
    
    end)

    wait(20)
    return false

end

myFunc()

will the player added event trigger even after 20 seconds?

My guess would be no

Even though Server Scripts may run at the moment the server first runs, it may not listen for the PlayerAdded event ahead of time until another player joins to print that plr variable

(Not sure though)

You could try using connections.

E.g.

local Connections = {}

Connections.PlayerAdded = Players.PlayerAdded:Connect(function(plr)
    print(plr)
end)
wait(20)
Connections.PlayerAdded:Disconnect()