This is the answer to the question How to show(or hide) the UMG on the specific screen(viewport) with nDisplay? - UI - Unreal Engine Forums
I’m sorry, but I haven’t figured out how I could leave a comment on the original page.
My implementation is for version 4.27. Every node runs this script at startup, which can be confusing. You don’t need to change any parameters, just the script will execute when the name of the node matches the specified one.